feat(tvldb): parse CTCP ACTIONs properly, allow use of aliases in ??! syntax
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>
This commit is contained in:
parent
356dde149f
commit
7e0b2cd3f3
1 changed files with 10 additions and 2 deletions
|
@ -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))?
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue