Fix bridging and refactor
This commit is contained in:
0
core/modules/__init__.py
Normal file
0
core/modules/__init__.py
Normal file
50
core/modules/router.py
Normal file
50
core/modules/router.py
Normal file
@@ -0,0 +1,50 @@
|
||||
from core.util import logs
|
||||
|
||||
from core.clients.signal import SignalClient
|
||||
from core.clients.xmpp import XMPPClient
|
||||
|
||||
class UnifiedRouter(object):
|
||||
"""
|
||||
Unified Router. Contains generic functions for handling XMPP and Signal events.
|
||||
"""
|
||||
|
||||
def __init__(self, loop):
|
||||
self.loop = loop
|
||||
|
||||
self.log = logs.get_logger("router")
|
||||
self.log.info("Initialised Unified Router Interface.")
|
||||
|
||||
self.xmpp = XMPPClient(self, loop, "xmpp")
|
||||
self.signal = SignalClient(self, loop, "signal")
|
||||
|
||||
def start(self):
|
||||
self.xmpp.start()
|
||||
self.signal.start()
|
||||
|
||||
|
||||
def run(self):
|
||||
try:
|
||||
self.xmpp.client.process()
|
||||
self.loop.run_forever()
|
||||
except (KeyboardInterrupt, SystemExit):
|
||||
self.log.info("Process terminating")
|
||||
finally:
|
||||
self.loop.close()
|
||||
|
||||
async def message_received(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Message received ({protocol}) {args} {kwargs}")
|
||||
|
||||
async def message_read(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Message read ({protocol}) {args} {kwargs}")
|
||||
|
||||
async def started_typing(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Started typing ({protocol}) {args} {kwargs}")
|
||||
|
||||
async def stopped_typing(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Stopped typing ({protocol}) {args} {kwargs}")
|
||||
|
||||
async def reacted(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Reacted ({protocol}) {args} {kwargs}")
|
||||
|
||||
async def replied(self, protocol, *args, **kwargs):
|
||||
self.log.info(f"Replied ({protocol}) {args} {kwargs}")
|
||||
Reference in New Issue
Block a user