Answer the question
In order to leave comments, you need to log in
How to isolate Handler in Telegram Bot in Python?
Good afternoon. I have a handler that accepts city names to get the weather forecast.
This handler should only work when the weather check function is called, but it always works in general and thus processes all messages.
How to isolate it so that it would only accept messages inside the function? or only 1 message for example.
@bot.message_handler(regexp="⛅️Узнать погоду")
def checkWeather(message):
global keyboardWeather
keyboardWeather = telebot.types.ReplyKeyboardMarkup()
keyboardWeather.row('⭐️Мои места','Выход')
bot.send_message(message.chat.id, "Напиши мне название города, или выбери из своих мест.", reply_markup=keyboardWeather)
@bot.message_handler(content_types=['text'])
def handle_message(message):
place = message.text
.........
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