Add check if poll has already been started
This commit is contained in:
parent
d5ffa6952f
commit
29674b92eb
|
@ -171,9 +171,7 @@ class Command:
|
||||||
# Add newly created room to space
|
# Add newly created room to space
|
||||||
space_child_content = {
|
space_child_content = {
|
||||||
"suggested": False,
|
"suggested": False,
|
||||||
"via": [
|
"via": [self.client.server],
|
||||||
self.client.user_id.split(":", maxsplit=1)[1]
|
|
||||||
], # the bot's homeserver
|
|
||||||
}
|
}
|
||||||
space_resp = await self.client.room_put_state(
|
space_resp = await self.client.room_put_state(
|
||||||
room_id=self.config.vetting_space_id,
|
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!"
|
text = "This user hasn't been vetted, can't vote on them!"
|
||||||
await send_text_to_room(self.client, self.room.room_id, text)
|
await send_text_to_room(self.client, self.room.room_id, text)
|
||||||
return
|
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?"
|
poll_text = f"Accept {vetted_user_id} into the Federation?"
|
||||||
choices = ["yes", "no", "blank"]
|
choices = ["yes", "no", "blank"]
|
||||||
|
|
|
@ -105,6 +105,9 @@ async def main():
|
||||||
# Login succeeded!
|
# Login succeeded!
|
||||||
|
|
||||||
logger.info(f"Logged in as {config.user_id}")
|
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)
|
await client.sync_forever(timeout=30000, full_state=True)
|
||||||
|
|
||||||
except (ClientConnectionError, ServerDisconnectedError):
|
except (ClientConnectionError, ServerDisconnectedError):
|
||||||
|
|
Loading…
Reference in New Issue