Move bot helper checks to command event handler

This commit is contained in:
Tulir Asokan 2018-10-17 22:45:59 +03:00
parent 06eef9d6f2
commit cc053d0cfc

View File

@ -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)