fix(matrix): ignore m.notice messages to prevent bot-to-bot loops

The old nio code only handled RoomMessageText (m.text). The mautrix
rewrite dispatched both m.text and m.notice, which would cause infinite
loops between bots since m.notice is the conventional msgtype for bot
responses in the Matrix ecosystem.
This commit is contained in:
alt-glitch
2026-04-11 07:44:55 +05:30
committed by Teknium
parent 0286f9de22
commit 68f5d358a0
+6 -1
View File
@@ -909,11 +909,16 @@ class MatrixAdapter(BasePlatformAdapter):
if relates_to.get("rel_type") == "m.replace":
return
# Ignore m.notice to prevent bot-to-bot loops (m.notice is the
# conventional msgtype for bot responses in the Matrix ecosystem).
if msgtype == "m.notice":
return
# Dispatch by msgtype.
media_msgtypes = ("m.image", "m.audio", "m.video", "m.file")
if msgtype in media_msgtypes:
await self._handle_media_message(room_id, sender, event_id, event_ts, source_content, relates_to, msgtype)
elif msgtype in ("m.text", "m.notice"):
elif msgtype == "m.text":
await self._handle_text_message(room_id, sender, event_id, event_ts, source_content, relates_to)
async def _resolve_message_context(