Answer the question
In order to leave comments, you need to log in
A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found?
I decided to start learning Python with a simple Tg Bot, I can’t figure out why when I press the Inline Button after the /test command, the Bot crashes with an Error. A request to the Telegram API was unsuccessful. Error code: 400. Description: Bad Request: chat not found ? Do not beat pzh, I'm learning python for 3 days.
@bot.message_handler(commands=['dz'])
def start_message(message):
markup = telebot.types.InlineKeyboardMarkup()
markup.add(telebot.types.InlineKeyboardButton(text='Понедельник', callback_data=1))
markup.add(telebot.types.InlineKeyboardButton(text='Вторник', callback_data=2))
markup.add(telebot.types.InlineKeyboardButton(text='Среда', callback_data=3))
markup.add(telebot.types.InlineKeyboardButton(text='Четверг', callback_data=4))
markup.add(telebot.types.InlineKeyboardButton(text='Пятница', callback_data=5))
markup.add(telebot.types.InlineKeyboardButton(text='Суббота', callback_data=6))
markup.add(telebot.types.InlineKeyboardButton(text='Завтра', callback_data=7))
bot.send_message(message.chat.id, text="На какой день недели ?", reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def query_handler(call):
answer = ''
if call.data == '1':
answer = dz.ponedelnik
elif call.data == '2':
answer = dz.vtornik
elif call.data == '3':
answer = dz.sreda
elif call.data == '4':
answer = dz.chetverg
elif call.data == '5':
answer = dz.pyatnica
elif call.data == '6':
answer = dz.subbota
elif call.data == '7':
answer = dz.weekday
bot.send_message(call.message.chat.id, answer)
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id)
@bot.message_handler(commands=['test'])
def start_message(message):
marku = telebot.types.InlineKeyboardMarkup()
marku.add(telebot.types.InlineKeyboardButton(text='Понедельник', callback_data=8))
marku.add(telebot.types.InlineKeyboardButton(text='Вторник', callback_data=9))
marku.add(telebot.types.InlineKeyboardButton(text='Среда', callback_data=10))
marku.add(telebot.types.InlineKeyboardButton(text='Четверг', callback_data=11))
marku.add(telebot.types.InlineKeyboardButton(text='Пятница', callback_data=12))
marku.add(telebot.types.InlineKeyboardButton(text='Суббота', callback_data=13))
marku.add(telebot.types.InlineKeyboardButton(text='Завтра', callback_data=14))
bot.send_message(message.chat.id, text="На какой день недели ?", reply_markup=marku)
@bot.callback_query_handler(func=lambda call: True)
def handler(call):
answer1 = ''
if call.data == '8':
answer1 = dz.ponedelnik
elif call.data == '9':
answer1 = dz.vtornik
elif call.data == '10':
answer1 = dz.sreda
elif call.data == '11':
answer1 = dz.chetverg
elif call.data == '12':
answer1 = dz.pyatnica
elif call.data == '13':
answer1 = dz.subbota
elif call.data == '14':
answer1 = dz.weekday
bot.send_message(call.message.chat.id, answer1)
bot.edit_message_reply_markup(call.message.chat.id, call.message.message_id)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question