mirror of
https://github.com/father-bot/chatgpt_telegram_bot.git
synced 2026-06-13 03:54:57 +03:00
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:
+18
-1
@@ -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()
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user