diff --git a/README.md b/README.md index 1e2c50d..b066e6f 100644 --- a/README.md +++ b/README.md @@ -59,21 +59,6 @@ mv config/config.example.env config/config.env docker-compose --env-file config/config.env up --build ``` - -## Configure command hints (optional, but fancy) - -At [@BotFather](https://t.me/BotFather), use command `/mybots` -> select your bot -> Edit Bot -> Edit Commands. Then paste the following text to the BotFather: - -``` -retry - Regenerate last bot answer -new - Start new dialog -mode - Select chat mode -balance - Show balance -help - Show help -``` - -After that, you will be able to utilize menu shortcuts or receive prompts while entering commands. - ## ❤️ Top donations You can be in this list: diff --git a/bot/bot.py b/bot/bot.py index 115098f..75dcc64 100644 --- a/bot/bot.py +++ b/bot/bot.py @@ -9,8 +9,15 @@ from pathlib import Path from datetime import datetime import telegram -from telegram import Update, User, InlineKeyboardButton, InlineKeyboardMarkup +from telegram import ( + Update, + User, + InlineKeyboardButton, + InlineKeyboardMarkup, + BotCommand +) from telegram.ext import ( + Application, ApplicationBuilder, CallbackContext, CommandHandler, @@ -299,11 +306,21 @@ async def error_handle(update: Update, context: CallbackContext) -> None: except: await context.bot.send_message(update.effective_chat.id, "Some error in error handler") +async def post_init(application: Application): + await application.bot.set_my_commands([ + BotCommand("/new", "Start new dialog"), + BotCommand("/mode", "Select chat mode"), + BotCommand("/retry", "Re-generate response for previous query"), + BotCommand("/balance", "Show balance"), + BotCommand("/help", "Show help message"), + ]) + def run_bot() -> None: application = ( ApplicationBuilder() .token(config.telegram_token) .concurrent_updates(True) + .post_init(post_init) .build() )