diff options
Diffstat (limited to 'bot.py')
-rw-r--r-- | bot.py | 22 |
1 files changed, 19 insertions, 3 deletions
@@ -42,6 +42,7 @@ from command import ( | |||
42 | help_command, | 42 | help_command, |
43 | tos_command, | 43 | tos_command, |
44 | toggle_visibility_command, | 44 | toggle_visibility_command, |
45 | callback_toggle_visibility, | ||
45 | logout_command, | 46 | logout_command, |
46 | list_command | 47 | list_command |
47 | ) | 48 | ) |
@@ -55,7 +56,8 @@ from config import ( | |||
55 | ADD_COMMENT, | 56 | ADD_COMMENT, |
56 | BOT_TOKEN, | 57 | BOT_TOKEN, |
57 | BOT_SCOPE, | 58 | BOT_SCOPE, |
58 | MAIN_MENU | 59 | MAIN_MENU, |
60 | WAIT_VISIBILITY | ||
59 | ) | 61 | ) |
60 | 62 | ||
61 | from prompt.string import PROMPT_CHOOSE_ACTION | 63 | from prompt.string import PROMPT_CHOOSE_ACTION |
@@ -161,13 +163,27 @@ async def main() -> None: | |||
161 | 163 | ||
162 | # register handlers | 164 | # register handlers |
163 | application.add_handler(CommandHandler("tos", tos_command)) | 165 | application.add_handler(CommandHandler("tos", tos_command)) |
164 | application.add_handler(CommandHandler("vis", toggle_visibility_command)) | 166 | visibility_conversation_handler = ConversationHandler( |
167 | entry_points=[ | ||
168 | CommandHandler("vis", toggle_visibility_command) | ||
169 | ], | ||
170 | states={ | ||
171 | WAIT_VISIBILITY: [ | ||
172 | CallbackQueryHandler(callback_toggle_visibility) | ||
173 | ]}, | ||
174 | fallbacks=[CommandHandler("cancel", cancel_command)], | ||
175 | per_message=False, | ||
176 | allow_reentry=True, | ||
177 | ) | ||
178 | |||
165 | application.add_handler(CommandHandler("logout", logout_command)) | 179 | application.add_handler(CommandHandler("logout", logout_command)) |
166 | application.add_handler(CommandHandler("list", list_command)) | 180 | application.add_handler(CommandHandler("list", list_command)) |
167 | application.add_handler(CommandHandler("Help", help_command)) | 181 | application.add_handler(CommandHandler("Help", help_command)) |
168 | application.add_handler(checkin_handler) | ||
169 | application.add_handler(TypeHandler(type=FediLoginCallbackUpdate, callback=process_oauth_login_callback)) | 182 | application.add_handler(TypeHandler(type=FediLoginCallbackUpdate, callback=process_oauth_login_callback)) |
170 | 183 | ||
184 | application.add_handler(visibility_conversation_handler, 2) | ||
185 | application.add_handler(checkin_handler, 1) | ||
186 | |||
171 | # Pass webhook settings to telegram | 187 | # Pass webhook settings to telegram |
172 | await application.bot.set_webhook(url=f"{BOT_DOMAIN}{TELEGRAM_WEBHOOK_URL}") | 188 | await application.bot.set_webhook(url=f"{BOT_DOMAIN}{TELEGRAM_WEBHOOK_URL}") |
173 | 189 | ||