Ignore own events and fix initial pattern match
This commit is contained in:
parent
1245e6540a
commit
d237d3bbc9
1 changed files with 4 additions and 2 deletions
|
@ -112,7 +112,7 @@ class Rule:
|
||||||
if len(self.rooms) > 0 and evt.room_id not in self.rooms:
|
if len(self.rooms) > 0 and evt.room_id not in self.rooms:
|
||||||
return None
|
return None
|
||||||
for pattern in self.matches:
|
for pattern in self.matches:
|
||||||
match = pattern.match(evt.content.body)
|
match = pattern.search(evt.content.body)
|
||||||
if match:
|
if match:
|
||||||
return match
|
return match
|
||||||
return None
|
return None
|
||||||
|
@ -154,7 +154,9 @@ class ReactBot(Plugin):
|
||||||
for name, rule in self.config["rules"].items()}
|
for name, rule in self.config["rules"].items()}
|
||||||
|
|
||||||
@event.on(EventType.ROOM_MESSAGE)
|
@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():
|
for name, rule in self.rules.items():
|
||||||
match = rule.match(evt)
|
match = rule.match(evt)
|
||||||
if match is not None:
|
if match is not None:
|
||||||
|
|
Loading…
Reference in a new issue