aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMax Audron <audron@cocaine.farm>2021-09-07 12:38:34 +0200
committerMax Audron <audron@cocaine.farm>2021-09-07 12:38:34 +0200
commitda6acb3a3018449161a96ad093405bbfc13d6133 (patch)
tree93a7cfcf257d745d66b0765cb21119320583ef6d /src
parentadd rmr to channels (diff)
handle error cases in sed module
Diffstat (limited to '')
-rw-r--r--src/hooks/sed.rs23
1 files changed, 15 insertions, 8 deletions
diff --git a/src/hooks/sed.rs b/src/hooks/sed.rs
index cb17ed2..8ae1a18 100644
--- a/src/hooks/sed.rs
+++ b/src/hooks/sed.rs
@@ -16,8 +16,11 @@ impl Sed {
Sed(HashMap::new())
}
- pub fn log(&mut self, _bot: &crate::Bot, msg: Message) -> Result<()> {
- self.log_msg(msg)
+ pub fn log(&mut self, _bot: &crate::Bot, msg: Message) {
+ match self.log_msg(msg) {
+ Ok(_) => (),
+ Err(err) => tracing::error!("failed to log new message: {:?}", err),
+ }
}
fn log_msg(&mut self, msg: Message) -> Result<()> {
@@ -39,13 +42,17 @@ impl Sed {
Ok(())
}
- pub fn replace(&mut self, bot: &crate::Bot, msg: Message) -> Result<()> {
+ pub fn replace(&mut self, bot: &crate::Bot, msg: Message) {
match self.find_and_replace(&msg) {
- Ok(res) => {
- bot.send_privmsg(msg.response_target().unwrap(), res.as_str())?;
- Ok(())
- }
- Err(_) => Ok(()),
+ Ok(res) => match bot.send_privmsg(msg.response_target().unwrap(), res.as_str()) {
+ Ok(_) => (),
+ Err(_) => tracing::error!(
+ "failed to send message: \"{:?}\" to channel: {:?}",
+ msg.response_target().unwrap(),
+ res
+ ),
+ },
+ Err(_) => tracing::debug!("did not find match for: {:?}", msg),
}
}
e required to access the parsed regex, this required a patch to the sedregex crate which did not get merged due to an inactive dev, blocking us from publishing on crates.Io 2. We wanted to highlight the changes done in bold 3. We want to add execution of multiple chained sed commands in the future which would require more modification 2021-10-19add formatting trait for irc codesMax Audron-0/+129 add an impl off the formatting trait on String to format Strings with the typical irc formatting codes for bold, italic etc 2021-10-17fix links in readmeMax Audron-2/+2