diff options
| -rw-r--r-- | src/plugins/unicode.rs | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/src/plugins/unicode.rs b/src/plugins/unicode.rs index 56c8666..c227513 100644 --- a/src/plugins/unicode.rs +++ b/src/plugins/unicode.rs @@ -67,19 +67,20 @@ impl<C: FrippyClient> Plugin for Unicode<C> { } fn command(&self, client: &Self::Client, command: PluginCommand) -> Result<(), FrippyError> { - if command.tokens.is_empty() || command.tokens[0].is_empty() { - let msg = "No non-space character was found."; + let token = match command.tokens.iter().find(|t| !t.is_empty()) { + Some(t) => t, + None => { + let msg = "No non-space character was found."; - if let Err(e) = client.send_notice(command.source, msg) { - Err(e.context(FrippyErrorKind::Connection))?; - } - - return Ok(()); - } + if let Err(e) = client.send_notice(command.source, msg) { + Err(e.context(FrippyErrorKind::Connection))?; + } - let content = &command.tokens[0]; + return Ok(()); + } + }; - if let Err(e) = client.send_privmsg(command.target, &self.format_response(&content)) { + if let Err(e) = client.send_privmsg(command.target, &self.format_response(&token)) { Err(e.context(FrippyErrorKind::Connection))?; } |
