K
K
kirill_shym2021-08-14 19:09:36
Python
kirill_shym, 2021-08-14 19:09:36

How to change buttons when one is clicked in Telegram python bot?

I just started making bots, and I want to change the buttons, but I don't know how. I want to make it so that when the server button is pressed, buttons with the numbering of servers appear.

import telebot
from telebot import types
@bot.message_handler(commands=['start', 'help'])
@bot.message_handler(content_types=['text'])
def send_welcome (message):
  if message.text == '/start':
    keyboard = telebot.types.ReplyKeyboardMarkup(True)
    keyboard.add('Сервера', 'Цена', 'Скуп', 'Передача', 'FAQ')
    bot.send_message(message.from_user.id, 'Привет',reply_markup=keyboard )
  if message.text == 'Сервера':
    bot.send_message(message.from_user.id, 'В разработке.')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mikhail Krostelev, 2021-08-14
@kirill_shym

To the comments:
There are a lot of materials on the Internet with understandable code. One of the main skills is to be able to search for information
On the question:
In your case, try sending a message with a different keyboard. You somehow screwed the first set of buttons.

if message.text == 'Сервера':
    keyboard = telebot.types.ReplyKeyboardMarkup(True)
    keyboard.add('Первый', 'Второй', 'Третий')
    bot.send_message(message.from_user.id, 'Выбери сервер',  reply_markup=keyboard)

From myself:
Learn how to work with Inline buttons, it will be much better.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question