diff --git a/src/context.rs b/src/context.rs index 22b716a..e0bb8f1 100644 --- a/src/context.rs +++ b/src/context.rs @@ -4,16 +4,26 @@ // in separately by the caller. Git context and IRC digest // are now available through where-am-i.md and the memory graph. +use std::collections::HashSet; + /// Build context string for a prompt. /// notification_text is passed in from the notify module. pub fn build(_include_irc: bool, notification_text: &str) -> String { // Keep nudges short — Claude checks notifications via - // `poc-daemon status` on its own. Just mention the count. - let count = notification_text.matches("[irc.").count() - + notification_text.matches("[telegram.").count(); - if count > 0 { - format!("{count} pending notifications") - } else { - String::new() + // `poc-daemon status` on its own. Just mention how many channels + // have activity (not how many messages — one IRC channel can + // generate hundreds of lines). + let channels: HashSet<&str> = notification_text + .lines() + .filter_map(|l| l.strip_prefix('[')) + .filter_map(|l| l.split_once(']')) + .map(|(ch, _)| ch) + .filter(|ch| ch.starts_with("irc.") || ch.starts_with("telegram.")) + .collect(); + + match channels.len() { + 0 => String::new(), + 1 => "1 channel has notifications".to_string(), + n => format!("{n} channels have notifications"), } }