From 62fc5fd71ec8083c79475838d1ea421b535e991e Mon Sep 17 00:00:00 2001 From: Jokler Date: Mon, 29 Jul 2019 19:41:34 +0200 Subject: Unicode: Allow multiple spaces before token --- src/plugins/unicode.rs | 21 +++++++++++---------- 1 file 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 Plugin for Unicode { } 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))?; } -- cgit v1.2.3-70-g09d2