Parcourir la source

Add a status command

master
Steven Haussmann il y a 5 ans
Parent
révision
ff6ebbfbc4
1 fichiers modifiés avec 12 ajouts et 0 suppressions
  1. +12
    -0
      icon-poller.py

+ 12
- 0
icon-poller.py Voir le fichier

@@ -178,6 +178,16 @@ def cancel(update: Update, context: CallbackContext):
submissions[chat_id] = {} submissions[chat_id] = {}
del polls[chat_id] del polls[chat_id]


@ensure_chat
def show_status(update: Update, context: CallbackContext):
chat_id = update.effective_chat.id
if status[chat_id] == "closed":
context.bot.send_message(chat_id=chat_id, text="I am currently closed.")
elif status[chat_id] == "open":
context.bot.send_message(chat_id=chat_id, text=f"I am currently open for submissions. There are {len(submissions[chat_id])} submissions.")
elif status[chat_id] == "polling":
context.bot.send_message(chat_id=chat_id, text="I am currently polling.")



if __name__ == "__main__": if __name__ == "__main__":
try: try:
@@ -194,6 +204,8 @@ if __name__ == "__main__":
dispatcher.add_handler(CommandHandler("poll", start_poll)) dispatcher.add_handler(CommandHandler("poll", start_poll))
dispatcher.add_handler(CommandHandler("decide", decide_poll)) dispatcher.add_handler(CommandHandler("decide", decide_poll))
dispatcher.add_handler(CommandHandler("cancel", cancel)) dispatcher.add_handler(CommandHandler("cancel", cancel))
dispatcher.add_handler(CommandHandler("status", show_status))



updater.start_polling() updater.start_polling()
updater.idle() updater.idle()

Chargement…
Annuler
Enregistrer