Add check if poll has already been started

This commit is contained in:
Panoramic 2024-06-11 13:49:20 +03:00
parent d5ffa6952f
commit 29674b92eb
Signed by: Panoramic
GPG Key ID: 29FEDD73E66D32F1
2 changed files with 11 additions and 3 deletions

View File

@ -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"]

View File

@ -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):