From 4a59dce1cdd371c86d1b4453bb5884d9344442d8 Mon Sep 17 00:00:00 2001 From: Jokler Date: Thu, 31 Oct 2019 01:29:40 +0100 Subject: Quote: Fix info message and adjust get output --- src/plugins/quote/mod.rs | 33 ++++++++++++++++++++++----------- 1 file changed, 22 insertions(+), 11 deletions(-) (limited to 'src/plugins/quote/mod.rs') diff --git a/src/plugins/quote/mod.rs b/src/plugins/quote/mod.rs index c6e33fe..9b7e6f5 100644 --- a/src/plugins/quote/mod.rs +++ b/src/plugins/quote/mod.rs @@ -109,28 +109,39 @@ impl Quote { } }; - let quote = if let Some(quotee) = quotee { - self + let response = if let Some(quotee) = quotee { + let quote = self .quotes .read() .get_user_quote(quotee, channel, idx) - .context(ErrorKind::NotFound)? + .context(ErrorKind::NotFound)?; + + format!( + "\"{}\" - {}[{}/{}]", + quote.content, quote.quotee, quote.idx, count + ) } else { - self + let quote = self .quotes .read() .get_channel_quote(channel, idx) - .context(ErrorKind::NotFound)? + .context(ErrorKind::NotFound)?; + + format!( + "\"{}\" - {}[{}]", + quote.content, quote.quotee, quote.idx + ) }; - Ok(format!( - "\"{}\" - {}[{}/{}]", - quote.content, quote.quotee, idx, count - )) + Ok(response) } fn info(&self, command: &PluginCommand) -> Result { - let tokens = command.tokens.iter().filter(|t| !t.is_empty()).collect::>(); + let tokens = command + .tokens + .iter() + .filter(|t| !t.is_empty()) + .collect::>(); match tokens.len() { 0 => { let channel = &command.target; @@ -150,7 +161,7 @@ impl Quote { Ok(match count { 0 => Err(ErrorKind::NotFound)?, 1 => format!("{} has 1 quote", quotee), - _ => format!("{} has {} quotes", quotee, count), + _ => format!("{} has {} quotes", count, quotee), }) } _ => { -- cgit v1.2.3-70-g09d2