DeepTutor: Lifelong Personalized Tutoring. https://deeptutor.info/.
Python ai-agentsai-tutorclawbotcli-tooldeepresearchinteractive-learninglearningmulti-agent-systemsrag
fix(zulip): 支持所有mention flags类型修复频道@mention无响应问题
WeDoneac06a05e22e9
diff --git a/deeptutor/tutorbot/channels/zulip.py b/deeptutor/tutorbot/channels/zulip.pyindex 893040fd5..6abd0c8d7 100644--- a/deeptutor/tutorbot/channels/zulip.py+++ b/deeptutor/tutorbot/channels/zulip.py@@ -352,12 +352,16 @@ class ZulipChannel(BaseChannel):msg_type = message.get("type", "")content = message.get("content", "")flags = message.get("flags", [])- logger.debug(- "Zulip message: type={}, flags={}, sender={}, subject={}",+ sender_email = message.get("sender_email", "?")+ subject = message.get("subject", "")+ display_recipient = message.get("display_recipient", "")+ logger.info(+ "Zulip message received: type={}, flags={}, sender={}, stream={}, topic={}",msg_type,flags,- message.get("sender_email", "?"),- message.get("subject", ""),+ sender_email,+ display_recipient if msg_type == "stream" else "N/A",+ subject,)content_type = message.get("content_type", "text/x-markdown")if content_type == "text/x-markdown":@@ -378,12 +382,14 @@ class ZulipChannel(BaseChannel):chat_id = self._stream_chat_id(stream_name, topic)if self.config.group_policy == "mention":if not self._is_mentioned(message):- logger.debug(- "Zulip stream message ignored (not mentioned): stream={}, topic={}",+ logger.info(+ "Zulip stream message ignored (not mentioned): stream={}, topic={}, flags={}",stream_name,topic,+ message.get("flags", []),)return+ logger.info("Zulip stream message will be processed: stream={}, topic={}", stream_name, topic)content = f"**[{stream_name} > {topic}]** {content}"elif msg_type == "private":chat_id = f"pm:{sender_id}"@@ -443,10 +449,20 @@ class ZulipChannel(BaseChannel):def _is_mentioned(self, message: dict) -> bool:if self._bot_user_id is None:+ logger.warning("Zulip _is_mentioned: bot_user_id is None, cannot check mention")return False- for flag in message.get("flags", []):- if isinstance(flag, str) and flag == "mentioned":+ mention_flags = {+ "mentioned",+ "wildcard_mentioned",+ "stream_wildcard_mentioned",+ "topic_wildcard_mentioned",+ }+ flags = message.get("flags", [])+ for flag in flags:+ if isinstance(flag, str) and flag in mention_flags:+ logger.debug("Zulip _is_mentioned: found flag={}", flag)return True+ logger.debug("Zulip _is_mentioned: no mention flags found, flags={}", flags)return Falsedef _download_attachments(self, message: dict) -> list[str]:diff --git a/tests/services/tutorbot/test_zulip_channel.py b/tests/services/tutorbot/test_zulip_channel.pyindex 4471da342..8624c6e08 100644--- a/tests/services/tutorbot/test_zulip_channel.py+++ b/tests/services/tutorbot/test_zulip_channel.py@@ -178,6 +178,41 @@ class TestIsMentioned:ch._bot_user_id = Noneassert ch._is_mentioned({"flags": ["mentioned"]}) is False+ def test_wildcard_mentioned_flag(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["wildcard_mentioned"]}) is True++ def test_stream_wildcard_mentioned_flag(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["stream_wildcard_mentioned"]}) is True++ def test_topic_wildcard_mentioned_flag(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["topic_wildcard_mentioned"]}) is True++ def test_mentioned_with_other_flags(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["read", "mentioned", "starred"]}) is True++ def test_missing_flags_field(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({}) is False++ def test_flags_with_non_string_elements(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["mentioned", 123, None]}) is True++ def test_multiple_mention_flags(self):+ ch = _make_channel()+ ch._bot_user_id = 100+ assert ch._is_mentioned({"flags": ["mentioned", "wildcard_mentioned"]}) is True+class TestExtractUploadLinks:def test_markdown_image(self):