diff --git a/backend/src/userbot/handlers/raw/dispatcher.py b/backend/src/userbot/handlers/raw/dispatcher.py index 32e0bde..8f16c47 100644 --- a/backend/src/userbot/handlers/raw/dispatcher.py +++ b/backend/src/userbot/handlers/raw/dispatcher.py @@ -24,8 +24,9 @@ _MODULES = ( read_receipts, transcribed, ) -_REGISTRY: dict[type, RawHandler] = { - update_type: module.handle for module in _MODULES for update_type in module.HANDLES +_REGISTRY: dict[type, list[RawHandler]] = { + update_type: [module.handle for module in _MODULES if update_type in module.HANDLES] + for update_type in {kind for module in _MODULES for kind in module.HANDLES} } @@ -33,8 +34,7 @@ _REGISTRY: dict[type, RawHandler] = { async def dispatch( client: PyroClient, update: raw.base.Update, users: dict, chats: dict ) -> None: - handler = _REGISTRY.get(type(update)) - if handler is not None: + for handler in _REGISTRY.get(type(update), ()): await handler(client, update, users, chats)