M
M
marinavisotsky46872021-02-06 19:07:16
Python
marinavisotsky4687, 2021-02-06 19:07:16

How to pass message.text to the button click handler in Telebot?

@bot.message_handler(regexp=r'([a-z,0-9])')
def UserMessage(message):
    #Получаем текст от пользователя
    msg = message.text

Next, when you click on the button, you need to do something with this text.

How to submit here?
@bot.callback_query_handler(func=lambda call: True)
def ans(call):
    if call.data == "Кнопка":
        pass

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
marinavisotsky4687, 2021-02-06
@marinavisotsky4687

I solved the issue using global variables, I don’t know if it’s correct or not

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question