From da1e1df6dfa4c8da6198f8c5aa6080ae00c4c415 Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Thu, 6 Aug 2020 19:09:42 +0200 Subject: [PATCH 1/3] fix upload_keys --- README.md | 11 +++++++++++ matrix_bot/bot.py | 10 ++++------ 2 files changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index b4fb3cdb..ca3b7f0b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,11 @@ Create a virtualenv source venv/bin/activate pip install https://git.gaja-group.com/gaja-group/matrix-bot +## Configuration + +The configuration is stored in `$HOME/.config/matrix-bot/` and resides in directories within that directory. +By default the configuration file will be loaded from the `default` profile folder, this can be changed by running `matrix-bot -b PROFILE_NAME COMMANDS...` + ## Usage Before you can send encrypted messages you must verify the bot with the matrix homeserver. To to login and do this use `matrix-bot verify` @@ -37,3 +42,9 @@ Or start the bot in daemon mode. In this mode the bot will listen for defined ev cd MATRIX_BOT_DIR source venv/bin/activate matrix-bot run + +When the bot is running and the socket plugin is active you can send messages via the running bot. + + cd MATRIX_BOT_DIR + source venv/bin/activate + matrix-bot client send '!yourRoomId' "Message Content" diff --git a/matrix_bot/bot.py b/matrix_bot/bot.py index 34187592..06b11880 100644 --- a/matrix_bot/bot.py +++ b/matrix_bot/bot.py @@ -129,7 +129,8 @@ class Bot(object): return self.__client async def __upload_keys(self) -> None: - await self.client.keys_upload() + if self.client.should_upload_keys: + await self.client.keys_upload() if self.client.should_query_keys: await self.client.keys_query() @@ -140,12 +141,9 @@ class Bot(object): async def sync(self) -> None: self.logger.debug('Starting sync') - next_batch = self.__read_next_batch() - self.__upload_keys() + await self.__upload_keys() - await self.client.sync(timeout=30000, - full_state=True, - since=next_batch) + await self.client.sync(timeout=30000, full_state=True) async def sync_forever(self) -> None: # next_batch = self.__read_next_batch() From 6f1f9c598d0af8d52d1d3558efa99de7e8415ae1 Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Thu, 6 Aug 2020 19:47:25 +0200 Subject: [PATCH 2/3] Fix upload_keys --- matrix_bot/bot.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/matrix_bot/bot.py b/matrix_bot/bot.py index 06b11880..ac36265b 100644 --- a/matrix_bot/bot.py +++ b/matrix_bot/bot.py @@ -129,8 +129,7 @@ class Bot(object): return self.__client async def __upload_keys(self) -> None: - if self.client.should_upload_keys: - await self.client.keys_upload() + await self.client.keys_upload() if self.client.should_query_keys: await self.client.keys_query() @@ -141,9 +140,12 @@ class Bot(object): async def sync(self) -> None: self.logger.debug('Starting sync') + next_batch = self.__read_next_batch() await self.__upload_keys() - await self.client.sync(timeout=30000, full_state=True) + await self.client.sync(timeout=30000, + full_state=True, + since=next_batch) async def sync_forever(self) -> None: # next_batch = self.__read_next_batch() @@ -159,7 +161,7 @@ class Bot(object): self.logger.debug('Adding callbacks') client.add_to_device_callback(self.__to_device_callback, (KeyVerificationEvent, )) - self.__upload_keys() + await self.__upload_keys() click.secho('\nStarting verification process...', bold=True, fg='green') From cd3b03c3390afd260c0f6912dd9d9c2f77927b1f Mon Sep 17 00:00:00 2001 From: Patrick Neff Date: Thu, 6 Aug 2020 19:49:54 +0200 Subject: [PATCH 3/3] Fix upload_keys --- matrix_bot/bot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/matrix_bot/bot.py b/matrix_bot/bot.py index ac36265b..9db87641 100644 --- a/matrix_bot/bot.py +++ b/matrix_bot/bot.py @@ -129,7 +129,8 @@ class Bot(object): return self.__client async def __upload_keys(self) -> None: - await self.client.keys_upload() + if self.client.should_upload_keys: + await self.client.keys_upload() if self.client.should_query_keys: await self.client.keys_query()