aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/quote/mod.rs
diff options
context:
space:
mode:
authorJokler <jokler.contact@gmail.com>2019-10-31 01:29:40 +0100
committerJokler <jokler.contact@gmail.com>2019-10-31 01:29:40 +0100
commit4a59dce1cdd371c86d1b4453bb5884d9344442d8 (patch)
tree0f343faf3e692610aae6ff0bcb2f0ee4c4e46ac9 /src/plugins/quote/mod.rs
parent0685c9676ddf7b650796465e85c4e2d53f596e46 (diff)
downloadfrippy-4a59dce1cdd371c86d1b4453bb5884d9344442d8.tar.gz
frippy-4a59dce1cdd371c86d1b4453bb5884d9344442d8.zip
Quote: Fix info message and adjust get output
Diffstat (limited to 'src/plugins/quote/mod.rs')
-rw-r--r--src/plugins/quote/mod.rs33
1 files changed, 22 insertions, 11 deletions
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<T: Database, C: Client> Quote<T, C> {
}
};
- 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<String, QuoteError> {
- let tokens = command.tokens.iter().filter(|t| !t.is_empty()).collect::<Vec<_>>();
+ let tokens = command
+ .tokens
+ .iter()
+ .filter(|t| !t.is_empty())
+ .collect::<Vec<_>>();
match tokens.len() {
0 => {
let channel = &command.target;
@@ -150,7 +161,7 @@ impl<T: Database, C: Client> Quote<T, C> {
Ok(match count {
0 => Err(ErrorKind::NotFound)?,
1 => format!("{} has 1 quote", quotee),
- _ => format!("{} has {} quotes", quotee, count),
+ _ => format!("{} has {} quotes", count, quotee),
})
}
_ => {