D
D
Danila2019-12-20 20:12:50
Python
Danila, 2019-12-20 20:12:50

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

1 answer(s)
A
Andrey, 2019-12-21
@Dan9I

https://github.com/eternnoir/pyTelegramBotAPI/blob...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question