From a51840487f58b30b92a0d682c01662a74fa46379 Mon Sep 17 00:00:00 2001 From: Luna Date: Wed, 14 Jul 2021 15:04:33 -0300 Subject: [PATCH] pubsub: add passthrough logic --- litecord/pubsub/channel.py | 9 +++++---- litecord/pubsub/guild.py | 9 +++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/litecord/pubsub/channel.py b/litecord/pubsub/channel.py index 90c3293..ff0b7c1 100644 --- a/litecord/pubsub/channel.py +++ b/litecord/pubsub/channel.py @@ -69,10 +69,11 @@ class ChannelDispatcher( await self.unsub(channel_id, session_id) continue - wanted_intent = EVENTS_TO_INTENTS[event_type] - state_has_intent = (state.intents & wanted_intent) == wanted_intent - if not state_has_intent: - continue + wanted_intent = EVENTS_TO_INTENTS.get(event_type) + if wanted_intent is not None: + state_has_intent = (state.intents & wanted_intent) == wanted_intent + if not state_has_intent: + continue correct_event = event # for cases where we are talking about group dms, we create an edited diff --git a/litecord/pubsub/guild.py b/litecord/pubsub/guild.py index a8cb61c..db2b4d9 100644 --- a/litecord/pubsub/guild.py +++ b/litecord/pubsub/guild.py @@ -69,10 +69,11 @@ class GuildDispatcher( await self.unsub(guild_id, session_id) continue - wanted_intent = EVENTS_TO_INTENTS[event_type] - state_has_intent = (state.intents & wanted_intent) == wanted_intent - if not state_has_intent: - continue + wanted_intent = EVENTS_TO_INTENTS.get(event_type) + if wanted_intent is not None: + state_has_intent = (state.intents & wanted_intent) == wanted_intent + if not state_has_intent: + continue try: await state.ws.dispatch(*event)