aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2018-03-19 16:40:18 +0100
committerJokler <jokler.contact@gmail.com>2018-03-19 16:40:18 +0100
commit997707cfa933bec05faa281236911d893a8a9ba1 (patch)
tree9bb405d6ef97946a775fc8ffc32786e61da436bc /src
parent0e84a9c5cad2c5b8d4a2a9cff67c106ce4a47dfa (diff)
downloadfrippy-997707cfa933bec05faa281236911d893a8a9ba1.tar.gz
frippy-997707cfa933bec05faa281236911d893a8a9ba1.zip
Fix empty receivers getting accepted by Tell
Diffstat (limited to 'src')
-rw-r--r--src/plugins/tell/mod.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/src/plugins/tell/mod.rs b/src/plugins/tell/mod.rs
index b3c2195..a9c5da8 100644
--- a/src/plugins/tell/mod.rs
+++ b/src/plugins/tell/mod.rs
@@ -50,9 +50,10 @@ impl<T: Database> Tell<T> {
let mut online = Vec::new();
- let receivers = command.tokens[0].split(',');
+ let receivers = command.tokens[0].split(',').filter(|&s| !s.is_empty());
let sender = command.source;
+ let mut no_receiver = true;
for receiver in receivers {
if receiver.eq_ignore_ascii_case(client.current_nickname())
|| receiver.eq_ignore_ascii_case(&sender)
@@ -89,13 +90,19 @@ impl<T: Database> Tell<T> {
message: &message,
};
+ debug!("Saving tell for {:?}", receiver);
try_lock!(self.tells).insert_tell(&tell)?;
+ no_receiver = false;
}
- Ok(match online.len() {
- 0 => format!("Got it!"),
- 1 => format!("{} is currently online.", online[0]),
- _ => format!("{} are currently online.", online.join(", ")),
+ Ok(if no_receiver {
+ format!("Invalid receiver.")
+ } else {
+ match online.len() {
+ 0 => format!("Got it!"),
+ 1 => format!("{} is currently online.", online[0]),
+ _ => format!("{} are currently online.", online.join(", ")),
+ }
})
}