A
A
Alexey2020-11-01 20:24:51
Python
Alexey, 2020-11-01 20:24:51

Telebot,python how to request reusable input from user?

In general, there were difficulties with the assignment of the written text by the user.
The idea is this.
Login
is entered. Password is entered .

login = message.text
password = message.text

Doesn't work because password is set to login.
Tried
def login(message):
    msg1 = bot.send_message(message.chat.id,"Введите логин"
    login = message.text
    bot.register_next_step_handler(msg1, password)

def password(message):
    msg2 = bot.send_message(message.chat.id,"Введите пароль"
    password = message.text

In this case, between the first function and the second, you have to write some other message to the bot in order to go to 2 functions, and it is inconvenient to transfer global variables when they are used in both 1 function and 2. Is there any other way to enter something like this?
I will be grateful for the answer.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shurshur, 2020-11-02
@resolut1123

Look towards register_next_step_handler
Example: 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