From d3cedd9b2dc5346dad041e479bb1b3ab27f3c1cd Mon Sep 17 00:00:00 2001 From: jmbwell Date: Fri, 3 Oct 2025 17:15:01 +0000 Subject: [PATCH] more logging --- plugin.py | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 54 insertions(+), 2 deletions(-) diff --git a/plugin.py b/plugin.py index 4e402cf..e3a7c33 100644 --- a/plugin.py +++ b/plugin.py @@ -382,6 +382,12 @@ class Chat(callbacks.Plugin): return False decision = outcome.strip().split()[0].lower() + self.log.debug( + "Passive classifier outcome | decision=%s | raw=%s | channel=%s", + decision, + outcome.strip(), + msg.args[0], + ) return decision == "reply" def _should_respond_passively(self, irc, msg, session, events): @@ -393,30 +399,63 @@ class Chat(callbacks.Plugin): now = time.time() mention = self._is_direct_mention(irc, text) + self.log.debug( + "Passive evaluate | mode=%s | state=%s | nick=%s | channel=%s | mention=%s | replies=%s", + passive_mode, + session.state.value, + msg.nick, + msg.args[0], + mention, + session.replies_in_thread, + ) + if mention: if session.state == EngagementState.COOLING: session.reset() + self.log.debug( + "Passive reset session for mention during cooldown | channel=%s", + msg.args[0], + ) session.thread_owner = msg.nick session.last_invitation = now session.state = EngagementState.INVITED session.replies_in_thread = 0 + self.log.debug("Passive accepted mention | channel=%s", msg.args[0]) return True if session.state == EngagementState.COOLING: + self.log.debug( + "Passive skip: cooling | channel=%s | until=%.2f | now=%.2f", + msg.args[0], + session.cooling_until, + now, + ) return False if session.state in (EngagementState.INVITED, EngagementState.ENGAGED) and session.thread_owner: if ircutils.strEqual(msg.nick, session.thread_owner): + self.log.debug( + "Passive continuing thread with owner | channel=%s | owner=%s", + msg.args[0], + session.thread_owner, + ) return True if passive_mode == "mention": + self.log.debug("Passive skip: mention mode without mention | channel=%s", msg.args[0]) return False if session.state != EngagementState.IDLE: + self.log.debug( + "Passive skip: state not idle | channel=%s | state=%s", + msg.args[0], + session.state.value, + ) return False candidate = self._looks_like_question(text) or self._contains_trigger_word(text) if not candidate: + self.log.debug("Passive skip: heuristics failed | channel=%s", msg.args[0]) return False try: @@ -425,21 +464,28 @@ class Chat(callbacks.Plugin): probability = 0.0 if probability <= 0: + self.log.debug("Passive skip: probability disabled | channel=%s", msg.args[0]) return False roll = random.random() if roll > probability: - self.log.debug(f"Passive skip due to probability gate ({roll:.2f} > {probability:.2f})") + self.log.debug( + "Passive skip: probability gate | roll=%.2f | threshold=%.2f | channel=%s", + roll, + probability, + msg.args[0], + ) return False if not self._classify_passive_trigger(irc, msg, events): - self.log.debug("Passive classifier opted to skip reply") + self.log.debug("Passive skip: classifier veto | channel=%s", msg.args[0]) return False session.thread_owner = msg.nick session.last_invitation = now session.state = EngagementState.INVITED session.replies_in_thread = 0 + self.log.debug("Passive proceed: classifier approved | channel=%s", msg.args[0]) return True def doPrivmsg(self, irc, msg): @@ -482,6 +528,11 @@ class Chat(callbacks.Plugin): session.cooling_until = now + self.registryValue("passive_cooldown") session.thread_owner = None session.replies_in_thread = 0 + self.log.debug( + "Passive skip: reached max replies | channel=%s | max=%s", + msg.args[0], + max_replies, + ) return try: @@ -494,6 +545,7 @@ class Chat(callbacks.Plugin): return self.handle_response(irc, msg, response, session=session) + self.log.debug("Passive reply sent | channel=%s", msg.args[0]) def filter_prefix(self, msg, prefix): if msg.startswith(prefix):