From b7f0bd1bb44b8bfc1952489d7b9d04caa8202c11 Mon Sep 17 00:00:00 2001 From: Luna Mendes Date: Thu, 11 Oct 2018 16:52:15 -0300 Subject: [PATCH] run: pass app instance to EventDispatcher this should help with future DM channel pub/sub, as we'll have to query the `dm_channel_state` table. --- litecord/dispatcher.py | 5 +++-- litecord/pubsub/dispatcher.py | 1 + run.py | 4 ++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/litecord/dispatcher.py b/litecord/dispatcher.py index a1e2c58..b2d0ab2 100644 --- a/litecord/dispatcher.py +++ b/litecord/dispatcher.py @@ -11,8 +11,9 @@ log = Logger(__name__) class EventDispatcher: """Pub/Sub routines for litecord.""" - def __init__(self, sm): - self.state_manager = sm + def __init__(self, app): + self.state_manager = app.state_manager + self.app = app self.backends = { 'guild': GuildDispatcher(self), diff --git a/litecord/pubsub/dispatcher.py b/litecord/pubsub/dispatcher.py index 42d83e7..59cf08c 100644 --- a/litecord/pubsub/dispatcher.py +++ b/litecord/pubsub/dispatcher.py @@ -11,6 +11,7 @@ class Dispatcher: def __init__(self, main): self.main_dispatcher = main self.sm = main.state_manager + self.app = main.app async def sub(self, _key, _id): raise NotImplementedError diff --git a/run.py b/run.py index 45209bb..c48646b 100644 --- a/run.py +++ b/run.py @@ -93,9 +93,9 @@ async def app_before_serving(): g.loop = asyncio.get_event_loop() app.state_manager = StateManager() - app.dispatcher = EventDispatcher(app.state_manager) - app.storage = Storage(app.db) + + app.dispatcher = EventDispatcher(app) app.presence = PresenceManager(app.storage, app.state_manager, app.dispatcher) app.storage.presence = app.presence