From 009c32a884152de52c4d3341812a899012bffee0 Mon Sep 17 00:00:00 2001 From: andrew21-mch Date: Thu, 26 May 2022 07:25:55 +0100 Subject: [PATCH] added exit button --- src/app/bot.py | 9 ++++++++- src/app/menus.py | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/app/bot.py b/src/app/bot.py index 4da1ff8..c457947 100644 --- a/src/app/bot.py +++ b/src/app/bot.py @@ -75,6 +75,7 @@ def help_command(update: Update, context: CallbackContext): 'Pause': 'pause ongoing game \nPress', 'Resume': 'resume paused game \nPress', 'Stop': 'stop game \nPress', + 'Exit': 'Exit The Bot \nPress', } reply = 'OSSCAMEROON QUIZBOT HELP!:\n=====================\n' # format the help commands as type buttons @@ -128,6 +129,12 @@ def help_callback(update: Update, context: CallbackContext) -> None: f'Open this link: https://github.com/osscameroon/tg-gamebot ', reply_markup=back_inline_keyboard ) +def exit_command(update: Update, context: CallbackContext) -> None: + """Iddle bot activity until the user presses the /start command without killing the server""" + update.message.reply_text("Exiting Bot") + updater = Updater(BOT_API_KEY, use_context=True) + return updater.stop() + def menu_test(update: Update, context: CallbackContext) -> None: @@ -150,7 +157,7 @@ def handler(): dispatcher.add_handler(CommandHandler('resume', resume_command)) dispatcher.add_handler(CommandHandler('help', help_command)) dispatcher.add_handler(CommandHandler('menu', menu_command)) - + dispatcher.add_handler(CommandHandler('exit', exit_command)) # menu test dispatcher.add_handler(CommandHandler('menu_test', menu_test)) diff --git a/src/app/menus.py b/src/app/menus.py index 5f62ff9..94ae29e 100644 --- a/src/app/menus.py +++ b/src/app/menus.py @@ -28,6 +28,7 @@ [ KeyboardButton(text='About\n🆘️'), KeyboardButton(text='Help\nℹ'), + KeyboardButton(text='Exit \n❌'), ] ] )