diff options
| author | Jokler <jokler.contact@gmail.com> | 2019-07-29 19:41:34 +0200 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2019-07-29 19:41:34 +0200 |
| commit | 62fc5fd71ec8083c79475838d1ea421b535e991e (patch) | |
| tree | 7d2486263532cf73f22640fe251a925bd3dd277c /src | |
| parent | 4b95d4541b9e16c5e351eddaf1b0e883ed06c59d (diff) | |
| download | frippy-62fc5fd71ec8083c79475838d1ea421b535e991e.tar.gz frippy-62fc5fd71ec8083c79475838d1ea421b535e991e.zip | |
Unicode: Allow multiple spaces before token
Diffstat (limited to 'src')
| -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))?; } |
