Answer the question
In order to leave comments, you need to log in
PyTelegramBotAPI How to make keyboard appear after certain text?
I have a keyboard and I want that after a button is pressed, another keyboard and another function written by me come out. Tried if but keyboard didn't come out
# -*- coding: utf-8 -*-
import telebot import config
from telebot import types
bot = telebot.TeleBot(config.token)
@bot.message_handler(commands=["start"])
def startKBoard(message):
startKBoard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
Catalog = types.KeyboardButton(text="Каталог")
Info = types.KeyboardButton(text="Инофрмация")
startKBoard.add(Catalog, Info)
bot.send_message(message.chat.id, "Добро пожаловать в магазин цифровых товаров", re>
@bot.message_handler(content_types=['text'])
def catalogchk(message):
if message.text == "Каталог":
def catalogKBoard(message):
catalogKBoard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
Steam = types.KeyboardButton(text="Steam")
Origin = types.KeyboardButton(text="Origin")
UPlay = types.KeyboardButton(text="UPlay")
EpicGames = types.KeyboardButton(text="Epic Games")
VPN = types.KeyboardButton(text="VPN")
catalogKBoard.add(Steam, Origin, UPlay, EpicGames, VPN)
bot.send_message(message.chat.id, "Выберите Раздел")
if __name__ == '__main__':
bot.infinity_polling()
Help
Answer the question
In order to leave comments, you need to log in
Why are you making a function inside a function?
Do it like this
@bot.message_handler(content_types=['text'])
def catalogchk(message):
if message.text == "Каталог":
catalogKBoard = types.ReplyKeyboardMarkup(row_width=2, resize_keyboard=True)
Steam = types.KeyboardButton(text="Steam")
Origin = types.KeyboardButton(text="Origin")
UPlay = types.KeyboardButton(text="UPlay")
EpicGames = types.KeyboardButton(text="Epic Games")
VPN = types.KeyboardButton(text="VPN")
catalogKBoard.add(Steam, Origin, UPlay, EpicGames, VPN)
bot.send_message(message.chat.id, "Выберите Раздел", reply_markup=catalogKBoard)
def start_keyboard():
keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
Catalog = types.KeyboardButton(text="Каталог")
Info = types.KeyboardButton(text="Инофрмация")
keyboard.add(Catalog, Info)
return keyboard
def catalog_keyboard():
keyboard = types.ReplyKeyboardMarkup(row_width=1, resize_keyboard=True)
Steam = types.KeyboardButton(text="Steam")
Origin = types.KeyboardButton(text="Origin")
UPlay = types.KeyboardButton(text="UPlay")
EpicGames = types.KeyboardButton(text="Epic Games")
VPN = types.KeyboardButton(text="VPN")
keyboard.add(Steam, Origin, UPlay, EpicGames, VPN)
return keyboard
bot.send_message(message.chat.id, "Сообщение", reply_markup=catalog_keyboard())
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question