From 40ba7e54b6d440183ab0f6ca2976267f0e41bc83 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sun, 31 May 2020 20:20:54 +0100 Subject: [PATCH 1/3] Allow specifying a different config file location --- main.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/main.py b/main.py index ecdd1eb..6fea30c 100644 --- a/main.py +++ b/main.py @@ -2,6 +2,7 @@ import logging import asyncio +import sys from time import sleep from nio import ( AsyncClient, @@ -24,7 +25,13 @@ logger = logging.getLogger(__name__) async def main(): # Read config file - config = Config("config.yaml") + + # A different config file path can be specified as the first command line argument + if len(sys.argv) > 1: + config_filepath = sys.argv[1] + else: + config_filepath = "config.yaml" + config = Config(config_filepath) # Configure the database store = Storage(config.database_filepath) From 7d96c4731e5074d8625d5732d079426171261109 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sun, 31 May 2020 20:46:30 +0100 Subject: [PATCH 2/3] Add matrix-reminder-bot to projects list --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 817c90c..4d36f25 100644 --- a/README.md +++ b/README.md @@ -10,6 +10,8 @@ matrix-nio can be found * [anoadragon453/msc-chatbot](https://github.com/anoadragon453/msc-chatbot) - A matrix bot for matrix spec proposals * [anoadragon453/matrix-episode-bot](https://github.com/anoadragon453/matrix-episode-bot) - A matrix bot to post episode links * [TheForcer/vision-nio](https://github.com/TheForcer/vision-nio) - A general purpose matrix chatbot +* [anoadragon453/matrix-reminder-bot](https://github.com/anoadragon453/matrix-reminder-bot +) - A matrix bot to remind you about things Want your project listed here? [Edit this doc!](https://github.com/anoadragon453/nio-template/edit/master/README.md) From a49c7892515ddbbb8797132188a7608152137154 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sun, 31 May 2020 20:57:26 +0100 Subject: [PATCH 3/3] Encryption support is required --- config.py | 1 - main.py | 23 +++++++++-------------- sample.config.yaml | 5 ----- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/config.py b/config.py index 36f8033..b72b3ed 100644 --- a/config.py +++ b/config.py @@ -61,7 +61,6 @@ class Config(object): self.device_id = self._get_cfg(["matrix", "device_id"], required=True) self.device_name = self._get_cfg(["matrix", "device_name"], default="nio-template") self.homeserver_url = self._get_cfg(["matrix", "homeserver_url"], required=True) - self.enable_encryption = self._get_cfg(["matrix", "enable_encryption"], default=False) self.command_prefix = self._get_cfg(["command_prefix"], default="!c") + " " diff --git a/main.py b/main.py index 6fea30c..19b3cfa 100644 --- a/main.py +++ b/main.py @@ -41,7 +41,7 @@ async def main(): max_limit_exceeded=0, max_timeouts=0, store_sync_tokens=True, - encryption_enabled=config.enable_encryption, + encryption_enabled=True, ) # Initialize the matrix client @@ -73,19 +73,14 @@ async def main(): logger.error(f"Failed to login: %s", login_response.message) return False except LocalProtocolError as e: - # There's an edge case here where the user enables encryption but hasn't installed - # the correct C dependencies. In that case, a LocalProtocolError is raised on login. - # Warn the user if these conditions are met. - if config.enable_encryption: - logger.fatal( - "Failed to login and encryption is enabled. Have you installed the correct dependencies? " - "https://github.com/poljar/matrix-nio#installation" - ) - return False - else: - # We don't know why this was raised. Throw it at the user - logger.fatal("Error logging in: %s", e) - return False + # There's an edge case here where the user hasn't installed the correct C + # dependencies. In that case, a LocalProtocolError is raised on login. + logger.fatal( + "Failed to login. Have you installed the correct dependencies? " + "https://github.com/poljar/matrix-nio#installation " + "Error: %s", e + ) + return False # Login succeeded! diff --git a/sample.config.yaml b/sample.config.yaml index bfb16f4..1606b7f 100644 --- a/sample.config.yaml +++ b/sample.config.yaml @@ -18,11 +18,6 @@ matrix: device_id: ABCDEFGHIJ # What to name the logged in device device_name: nio-template - # End-to-end encryption support - # - # Enabling this requires installing the matrix-nio encryption dependencies - # as described here: https://github.com/poljar/matrix-nio#installation - enable_encryption: true storage: # The path to the database