Answer the question
In order to leave comments, you need to log in
How to transfer a variable from one function to another telebot?
Basically, I have this code:
bot.send_message(message.chat.id, 'Скажи свою фамилию')
bot.register_next_step_handler(message, last_name)
def last_name(message):
last_name = message.text
bot.send_message(message.chat.id, 'Скажи свое имя')
bot.register_next_step_handler(message, first_name)
def first_name(message):
firstName = message.text
bot.send_message(message.chat.id, f'{last_name} + f'{firtsName} + 'я вас запомнил')
last_name = message.text
.
Answer the question
In order to leave comments, you need to log in
in register_next_step_handler the first 2 parameters are the message and the function to be called. Next, parameters are passed if the called function has any parameters other than message.
bot.register_next_step_handler(message, first_name, < Parameter1 >, < Parameter2 >)
...
def first_name(message, < Parameter1 >, < Parameter2 >):
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question