BotServ: BOTSTATS per-channel activity
BOTSTATS <#channel> reports the lines the bot has seen this session and the top talkers. Tracked live in the network view (bounded per-nick map), recorded for bot-assigned channels only, and also fed to the shared stats registry as botserv.messages.
This commit is contained in:
parent
bddf13459d
commit
766ef6ca47
5 changed files with 75 additions and 0 deletions
|
|
@ -995,6 +995,11 @@ impl Engine {
|
|||
ctx.actions.push(resp);
|
||||
}
|
||||
}
|
||||
// BOTSTATS: count activity in channels that have a bot.
|
||||
if self.db.channel(to).is_some_and(|c| c.assigned_bot.is_some()) {
|
||||
self.network.record_line(to, &nick);
|
||||
self.bump("botserv.messages");
|
||||
}
|
||||
} else {
|
||||
let mut matched: Option<String> = None;
|
||||
{
|
||||
|
|
@ -2513,6 +2518,20 @@ mod tests {
|
|||
assert!(!say(&mut e, "goodbye all").iter().any(|a| matches!(a, NetAction::Privmsg { .. })), "no response on miss");
|
||||
}
|
||||
|
||||
// BOTSTATS reports per-channel activity the bot has seen this session.
|
||||
#[test]
|
||||
fn botserv_botstats_reports_activity() {
|
||||
let (mut e, _p) = kicker_fixture("bsbotstats");
|
||||
let bs = |e: &mut Engine, t: &str| e.handle(NetEvent::Privmsg { from: "000AAAAAB".into(), to: "42SAAAAAD".into(), text: t.into() });
|
||||
let say = |e: &mut Engine, t: &str| e.handle(NetEvent::Privmsg { from: "000AAAAAS".into(), to: "#c".into(), text: t.into() });
|
||||
say(&mut e, "one");
|
||||
say(&mut e, "two");
|
||||
say(&mut e, "three");
|
||||
let out = bs(&mut e, "BOTSTATS #c");
|
||||
assert!(out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("line(s) seen this session"))), "line count: {out:?}");
|
||||
assert!(out.iter().any(|a| matches!(a, NetAction::Notice { text, .. } if text.contains("spammer") && text.contains("3"))), "top talker listed: {out:?}");
|
||||
}
|
||||
|
||||
// The shared stats registry gathers per-service command counts, BotServ
|
||||
// events, and live gauges — the same pipe every module reports through.
|
||||
#[test]
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue