Can somebody tell me what am I doing wrong? The bot sends me an inline keyboard, but after clicking the button, I do not receive any callbacks (even the logger doesn't send anything).
Also, if I pass URL to inlineKeyboardButton it works properly
@bot.message_handler()
def add_city(message):
if user_status[message.chat.id] == Statuses.AddCity:
logger.info("User adding the city")
request = {
"name": message.text
}
response = requests.post(f'{api_url}/api/users/{message.chat.id}/add-city', json=request, headers=headers)
if response.status_code == 200:
logger.info("User got city. Waiting for confirmation")
data = response.json()
user_status[message.chat.id] = Statuses.ConfirmCity
markup = InlineKeyboardMarkup()
markup.add(InlineKeyboardButton("Confirm", callback_data="Confirm"))
markup.add(InlineKeyboardButton("Deny", callback_data="Deny"))
bot.send_message(message.chat.id, f'{data.get("name")}')
bot.send_message(message.chat.id, f'Підтверди що це саме те місто, яке ти хотів додати:',
reply_markup=markup)
else:
logger.info("Bad Request")
bot.send_message(message.chat.id, f'Виникла помилка при додаванні міста :(')
@bot.callback_query_handler(func=lambda call: call.data in ("Confirm", "Deny"))
def handle_city_confirmation(call):
logger.info(call)
if user_status[call.message.chat.id] == Statuses.ConfirmCity:
if call.data.split(' ')[0] == "Confirm":
bot.send_message(call.message.chat.id, 'success')
else:
bot.send_message(call.message.chat.id, "deny")
else:
bot.send_message(call.message.chat.id, "fail")
The solution was updating the token. Hope it will help someone