From d3ad338726b78915ee79e4a7d007daf3129e70f1 Mon Sep 17 00:00:00 2001 From: eta Date: Tue, 14 Jul 2020 18:47:37 +0100 Subject: fix(tvldb): unbreak quote grabbing Change-Id: Ib03561bbcc154aeee50a592332a2763ff784bb1d Reviewed-on: https://cl.tvl.fyi/c/depot/+/1165 Tested-by: BuildkiteCI Reviewed-by: eta Reviewed-by: glittershark --- fun/tvldb/src/main.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'fun') diff --git a/fun/tvldb/src/main.rs b/fun/tvldb/src/main.rs index f95b27656d1a..510cf0461b89 100644 --- a/fun/tvldb/src/main.rs +++ b/fun/tvldb/src/main.rs @@ -141,20 +141,21 @@ impl App { qlast: Captures, ) -> Result<(), Error> { let db = self.pg.get()?; + let nick_to_grab = &qlast["subj"].to_ascii_lowercase(); let mut kwd = self.keyword_from_captures(&qlast, nick, chan)?; let chan_lastmsgs = self .last_msgs .entry(chan.to_string()) .or_insert(HashMap::new()); // Use `nick` here, so things like "grfn: see glittershark" work. - let val = if let Some(last) = chan_lastmsgs.get(&nick.to_ascii_lowercase()) { + let val = if let Some(last) = chan_lastmsgs.get(nick_to_grab) { if last.starts_with("\x01ACTION ") { // Yes, this is inefficient, but it's better than writing some hacky CTCP parsing code // I guess (also, characters are hard, so just blindly slicing seems like a bad idea) - format!("* {} {}", nick, last.replace("\x01ACTION ", "").replace("\x01", "")) + format!("* {} {}", nick_to_grab, last.replace("\x01ACTION ", "").replace("\x01", "")) } else { - format!("<{}> {}", nick, last) + format!("<{}> {}", nick_to_grab, last) } } else { Err(format_err!("I dunno what {} said...", kwd.keyword.name))? -- cgit 1.4.1