From 29674b92ebf823c6fbcab9e94adb088cdff9080c Mon Sep 17 00:00:00 2001 From: Panoramic Date: Tue, 11 Jun 2024 13:49:20 +0300 Subject: [PATCH] Add check if poll has already been started --- vetting_bot/bot_commands.py | 11 ++++++++--- vetting_bot/main.py | 3 +++ 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/vetting_bot/bot_commands.py b/vetting_bot/bot_commands.py index b274f42..ab305ac 100644 --- a/vetting_bot/bot_commands.py +++ b/vetting_bot/bot_commands.py @@ -171,9 +171,7 @@ class Command: # Add newly created room to space space_child_content = { "suggested": False, - "via": [ - self.client.user_id.split(":", maxsplit=1)[1] - ], # the bot's homeserver + "via": [self.client.server], } space_resp = await self.client.room_put_state( room_id=self.config.vetting_space_id, @@ -206,6 +204,13 @@ class Command: text = "This user hasn't been vetted, can't vote on them!" await send_text_to_room(self.client, self.room.room_id, text) return + if row[1] is not None: + event_link = f"https://matrix.to/#/{self.config.vetting_room_id}/{row[1]}?via={self.client.server}" + text = ( + f"A poll has already been started for this user [here]({event_link})." + ) + await send_text_to_room(self.client, self.room.room_id, text) + return poll_text = f"Accept {vetted_user_id} into the Federation?" choices = ["yes", "no", "blank"] diff --git a/vetting_bot/main.py b/vetting_bot/main.py index 5b2b140..121212e 100644 --- a/vetting_bot/main.py +++ b/vetting_bot/main.py @@ -105,6 +105,9 @@ async def main(): # Login succeeded! logger.info(f"Logged in as {config.user_id}") + + client.server = client.user_id.split(":", maxsplit=1)[1] + await client.sync_forever(timeout=30000, full_state=True) except (ClientConnectionError, ServerDisconnectedError):