Answer the question
In order to leave comments, you need to log in
Bot not responding to commands?
The video on which I did it CLICK
Here is the code:
import telebot
from telebot import types
bot = telebot.TeleBot(''ТУТ ТОКЕН)
@bot.message_handler(content_types=['text'])
def ttt(message):
markup = types.ReplykeyboardMarkup(resize_keyboard=True)
but1 = types.KeyboardButton("1")
but2 = types.KeyboardButton("2")
markup.add(but1, but2)
if message.text == "1":
bot.send_message(message.chat.id, "1")
elif message.text == "2":
bot.send_message(message.chat.id, "2")
bot.polling(none_stop=True)
Answer the question
In order to leave comments, you need to log in
And what should be the reaction? Your click is not processed anywhere and the function is not used.
Because it is a handler for the text that has already arrived ("BONUS", etc.). And the buttons need to be inserted into the / start command handler
@bot.message_handler(commands=['start'])
def start(message):
markup = types.ReplyKeyboardMarkup(resize_keyboard=True)
butt_1 = types.KeyboardButton("ПОЛУЧИТЬ ДЕНЬГИ")
butt_2 = types.KeyboardButton("БОНУС")
markup.add(butt_1, butt_2)
bot.send_message(message.chat.id, "Чё надо?", reply_markup=markup)
open cmd
go to the project directory, i.e. write cd C:\project_folder
run the python file, i.e. write bot.py
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question