From d237d3bbc9f2b37caaeca3370f38300d56f26160 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 23 Jun 2019 02:02:02 +0300 Subject: [PATCH] Ignore own events and fix initial pattern match --- reactbot.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/reactbot.py b/reactbot.py index 6506a7d..7c7090d 100644 --- a/reactbot.py +++ b/reactbot.py @@ -112,7 +112,7 @@ class Rule: if len(self.rooms) > 0 and evt.room_id not in self.rooms: return None for pattern in self.matches: - match = pattern.match(evt.content.body) + match = pattern.search(evt.content.body) if match: return match return None @@ -154,7 +154,9 @@ class ReactBot(Plugin): for name, rule in self.config["rules"].items()} @event.on(EventType.ROOM_MESSAGE) - async def echo_handler(self, evt: MessageEvent) -> None: + async def event_handler(self, evt: MessageEvent) -> None: + if evt.sender == self.client.mxid: + return for name, rule in self.rules.items(): match = rule.match(evt) if match is not None: