Add commands suggestions via set_my_commands api method

* add command suggestions via set_my_commands method

* update README to remove manual instructions for bot menu
This commit is contained in:
Dmitry Gordin
2023-03-15 15:55:27 +06:00
committed by GitHub
parent 386e396c0b
commit 2b4d4ad860
2 changed files with 18 additions and 16 deletions
+18 -1
View File
@@ -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()
)