diff options
| author | Jokler <jokler.contact@gmail.com> | 2019-01-01 17:32:51 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2019-01-01 17:32:51 +0100 |
| commit | 731b236f09bf9a2e94ced66e9974091d95cf94f7 (patch) | |
| tree | b146dc67ddad92360c413d2adf4f6950ce9b0b93 | |
| parent | caf5fae723f9af78421cf154afd75ec7e344a0dd (diff) | |
| download | frippy-731b236f09bf9a2e94ced66e9974091d95cf94f7.tar.gz frippy-731b236f09bf9a2e94ced66e9974091d95cf94f7.zip | |
Tell: Fix unsent tell on PRIVMSG
| -rw-r--r-- | src/plugins/tell/mod.rs | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/plugins/tell/mod.rs b/src/plugins/tell/mod.rs index 3fcf5ef..3c0dc3d 100644 --- a/src/plugins/tell/mod.rs +++ b/src/plugins/tell/mod.rs @@ -17,6 +17,7 @@ use error::ErrorKind as FrippyErrorKind; use error::FrippyError; use failure::Fail; use failure::ResultExt; +use log::{debug, trace}; pub mod database; use self::database::Database; @@ -107,7 +108,8 @@ impl<T: Database, C: FrippyClient> Tell<T, C> { } fn on_namelist(&self, client: &C, channel: &str) -> Result<(), FrippyError> { - let receivers = self.tells + let receivers = self + .tells .read() .get_receivers() .context(FrippyErrorKind::Tell)?; @@ -130,6 +132,8 @@ impl<T: Database, C: FrippyClient> Tell<T, C> { } fn send_tells(&self, client: &C, receiver: &str) -> Result<(), FrippyError> { + trace!("Checking {} for tells", receiver); + if client.current_nickname() == receiver { return Ok(()); } @@ -153,14 +157,13 @@ impl<T: Database, C: FrippyClient> Tell<T, C> { let dur = now - Duration::new(tell.time.timestamp() as u64, 0); let human_dur = format_duration(dur); + let message = format!( + "Tell from {} {} ago: {}", + tell.sender, human_dur, tell.message + ); + client - .send_notice( - receiver, - &format!( - "Tell from {} {} ago: {}", - tell.sender, human_dur, tell.message - ), - ) + .send_notice(receiver, &message) .context(FrippyErrorKind::Connection)?; debug!( @@ -194,7 +197,7 @@ impl<T: Database, C: FrippyClient> Plugin for Tell<T, C> { let res = match message.command { Command::JOIN(_, _, _) => self.send_tells(client, message.source_nickname().unwrap()), Command::NICK(ref nick) => self.send_tells(client, nick), - Command::PRIVMSG(ref nick, _) => self.send_tells(client, nick), + Command::PRIVMSG(_, _) => self.send_tells(client, message.source_nickname().unwrap()), Command::Response(resp, ref chan_info, _) => { if resp == Response::RPL_NAMREPLY { debug!("NAMREPLY info: {:?}", chan_info); |
