about summary refs log tree commit diff
path: root/fun
diff options
context:
space:
mode:
authoreta <eta@theta.eu.org>2020-07-13T12·20+0100
committereta <eta@theta.eu.org>2020-07-13T17·00+0000
commit7e0b2cd3f36fd1bd0ef8fc0191f5887792c6d3a6 (patch)
treea5e2494237ac531fe7be455d4832c531e8a684ec /fun
parent356dde149f9a15a4f801a582c5f029f3a9812937 (diff)
feat(tvldb): parse CTCP ACTIONs properly, allow use of aliases in ??! syntax r/1269
Change-Id: I3cc0e88a94ea0edc470ff9e0da203f1193d40f9f
Reviewed-on: https://cl.tvl.fyi/c/depot/+/1128
Tested-by: BuildkiteCI
Reviewed-by: lukegb <lukegb@tvl.fyi>
Reviewed-by: glittershark <grfn@gws.fyi>
Diffstat (limited to 'fun')
-rw-r--r--fun/tvldb/src/main.rs12
1 files changed, 10 insertions, 2 deletions
diff --git a/fun/tvldb/src/main.rs b/fun/tvldb/src/main.rs
index 5d2e670337f6..f95b27656d1a 100644
--- a/fun/tvldb/src/main.rs
+++ b/fun/tvldb/src/main.rs
@@ -146,8 +146,16 @@ impl App {
             .last_msgs
             .entry(chan.to_string())
             .or_insert(HashMap::new());
-        let val = if let Some(last) = chan_lastmsgs.get(&kwd.keyword.name.to_ascii_lowercase()) {
-            format!("<{}> {}", &kwd.keyword.name, last)
+        // Use `nick` here, so things like "grfn: see glittershark" work.
+        let val = if let Some(last) = chan_lastmsgs.get(&nick.to_ascii_lowercase()) {
+            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", ""))
+            }
+            else {
+                format!("<{}> {}", nick, last)
+            }
         } else {
             Err(format_err!("I dunno what {} said...", kwd.keyword.name))?
         };