This commit is contained in:
夜坂雅 2023-06-11 23:39:22 +08:00
parent 1da8e6e0cb
commit a879944446
1 changed files with 2 additions and 8 deletions

View File

@ -1,4 +1,3 @@
import asyncio
import logging
import time
@ -41,7 +40,6 @@ class Callbacks:
self.room_features = config.room_features
self.command_prefix = config.command_prefix
self.replace_map = {}
self.tasks = set()
async def message(self, room: MatrixRoom, event: RoomMessageText) -> None:
"""Callback for when a message event is received
@ -102,9 +100,7 @@ class Callbacks:
message = Message(
self.client, self.config, msg, room, event, reply_to, self.room_features
)
task = asyncio.create_task(message.process())
self.tasks.add(task)
task.add_done_callback(self.tasks.discard)
await message.process()
# Treat it as a command only if it has a prefix
if has_command_prefix:
@ -121,9 +117,7 @@ class Callbacks:
self.replace_map,
self.command_prefix,
)
task = asyncio.create_task(command.process())
self.tasks.add(task)
task.add_done_callback(self.tasks.discard)
await command.process()
async def unknown(self, room: MatrixRoom, event: UnknownEvent) -> None:
"""Callback for when an event with a type that is unknown to matrix-nio is received.