From 2fa90fc4e084cea3783e6ff2893a9c83b97119da Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Mon, 23 Dec 2019 14:29:26 +0100 Subject: [PATCH] If matrix-nio is not installed, don't crash --- royalnet/__main__.py | 6 +++--- royalnet/serf/matrix/matrixserf.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/royalnet/__main__.py b/royalnet/__main__.py index 03b18e9a..11024b86 100644 --- a/royalnet/__main__.py +++ b/royalnet/__main__.py @@ -58,7 +58,7 @@ def run(config_filename: str): # Serfs telegram_process = None - if config["Serfs"]["Telegram"]["enabled"]: + if "Telegram" in config["Serfs"] and config["Serfs"]["Telegram"]["enabled"]: telegram_process = multiprocessing.Process(name="Serf.Telegram", target=rs.telegram.TelegramSerf.run_process, daemon=True, @@ -76,7 +76,7 @@ def run(config_filename: str): log.info("Serf.Telegram: Disabled") discord_process = None - if config["Serfs"]["Discord"]["enabled"]: + if "Discord" in config["Serfs"] and config["Serfs"]["Discord"]["enabled"]: discord_process = multiprocessing.Process(name="Serf.Discord", target=rs.discord.DiscordSerf.run_process, daemon=True, @@ -94,7 +94,7 @@ def run(config_filename: str): log.info("Serf.Discord: Disabled") matrix_process = None - if config["Serfs"]["Matrix"]["enabled"]: + if "Matrix" in config["Serfs"] and config["Serfs"]["Matrix"]["enabled"]: matrix_process = multiprocessing.Process(name="Serf.Matrix", target=rs.matrix.MatrixSerf.run_process, daemon=True, diff --git a/royalnet/serf/matrix/matrixserf.py b/royalnet/serf/matrix/matrixserf.py index c36dd3cd..adf3f8a0 100644 --- a/royalnet/serf/matrix/matrixserf.py +++ b/royalnet/serf/matrix/matrixserf.py @@ -95,7 +95,7 @@ class MatrixSerf(Serf): return DiscordData - async def handle_message(self, room: nio.MatrixRoom, event: nio.RoomMessageText): + async def handle_message(self, room: "nio.MatrixRoom", event: "nio.RoomMessageText"): # Skip events happened before the startup of the Serf if event.server_timestamp < self._started_timestamp: return