add intents support to channel dispatcher

This commit is contained in:
Luna 2021-07-14 14:59:34 -03:00
parent dae56a68ae
commit bc1c0f3b20
1 changed files with 4 additions and 8 deletions

View File

@ -23,7 +23,7 @@ from dataclasses import dataclass
from quart import current_app as app
from logbook import Logger
from litecord.enums import ChannelType
from litecord.enums import ChannelType, EVENTS_TO_INTENTS
from litecord.utils import index_by_func
from .dispatcher import DispatcherWithFlags, GatewayEvent
@ -69,13 +69,9 @@ class ChannelDispatcher(
await self.unsub(channel_id, session_id)
continue
try:
flags = self.get_flags(channel_id, session_id)
except KeyError:
log.warning("no flags for {!r}, ignoring", session_id)
flags = ChannelFlags(typing=True)
if event_type.lower().startswith("typing_") and not flags.typing:
wanted_intent = EVENTS_TO_INTENTS[event_type]
state_has_intent = (state.intents & wanted_intent) == wanted_intent
if not state_has_intent:
continue
correct_event = event