mirror of
https://github.com/maubot/maubot.git
synced 2024-10-01 01:06:10 -04:00
Move bot helper checks to command event handler
This commit is contained in:
parent
06eef9d6f2
commit
cc053d0cfc
@ -84,6 +84,8 @@ class MaubotMatrixClient(MatrixClient):
|
|||||||
pass
|
pass
|
||||||
|
|
||||||
async def _command_event_handler(self, evt: MessageEvent) -> None:
|
async def _command_event_handler(self, evt: MessageEvent) -> None:
|
||||||
|
if evt.sender == self.mxid or evt.content.msgtype != MessageType.TEXT:
|
||||||
|
return
|
||||||
for command in self.commands:
|
for command in self.commands:
|
||||||
if command.match(evt):
|
if command.match(evt):
|
||||||
await self._trigger_command(command, evt)
|
await self._trigger_command(command, evt)
|
||||||
@ -114,8 +116,6 @@ class MaubotMatrixClient(MatrixClient):
|
|||||||
|
|
||||||
async def call_handlers(self, event: Event) -> None:
|
async def call_handlers(self, event: Event) -> None:
|
||||||
if isinstance(event, MessageEvent):
|
if isinstance(event, MessageEvent):
|
||||||
if event.sender == self.mxid:
|
|
||||||
return
|
|
||||||
event = MaubotMessageEvent(event, self)
|
event = MaubotMessageEvent(event, self)
|
||||||
return await super().call_handlers(event)
|
return await super().call_handlers(event)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user