diff options
| author | Jokler <jokler.contact@gmail.com> | 2019-12-24 00:22:32 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2019-12-24 00:22:32 +0100 |
| commit | d9cebeb6a7d5cce181121190ac122df29fe6d5c6 (patch) | |
| tree | fc0a3dc2e86414ef09e15f3e5d3923343f9aa693 /src/plugins/quote/mod.rs | |
| parent | 46b36045d701d5727f4000790780025e38f94f8a (diff) | |
| download | frippy-d9cebeb6a7d5cce181121190ac122df29fe6d5c6.tar.gz frippy-d9cebeb6a7d5cce181121190ac122df29fe6d5c6.zip | |
Quote: Filter out empty tokens on get
Diffstat (limited to 'src/plugins/quote/mod.rs')
| -rw-r--r-- | src/plugins/quote/mod.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/plugins/quote/mod.rs b/src/plugins/quote/mod.rs index 893b3e6..7223b42 100644 --- a/src/plugins/quote/mod.rs +++ b/src/plugins/quote/mod.rs @@ -96,12 +96,17 @@ impl<T: Database, C: Client> Quote<T, C> { } fn get(&self, command: &PluginCommand) -> Result<String, QuoteError> { - let quotee = &command.tokens.get(0); + let tokens = command + .tokens + .iter() + .filter(|t| !t.is_empty()) + .collect::<Vec<_>>(); + let quotee = &tokens.get(0); let channel = &command.target; match quotee { Some(quotee) => { - let idx = match command.tokens.get(1) { + let idx = match tokens.get(1) { Some(s) => Some(i32::from_str(s).context(ErrorKind::InvalidIndex)?), None => None, }; |
