Answer the question
In order to leave comments, you need to log in
How to save user data?
There is a code
user_data= {
'name': '',
'phone': '',
'email': '',
'message': ''
}
@bot.message_handler(commands=['start', 'go'])
def start_handler(message):
msg = bot.send_message(message.chat.id, 'Введите Ваше ФИО')
bot.register_next_step_handler(msg, user_phone)
def user_phone(message):
user_data['name'] = message.text
msg = bot.send_message(message.chat.id, 'Введите свой номер телефона')
bot.register_next_step_handler(msg, user_email)
def user_email(message):
user_data['phone'] = message.text
msg = bot.send_message(message.chat.id, 'Введите Вашу эл. почту')
bot.register_next_step_handler(msg, user_message)
def user_message(message):
user_data['email'] = message.text
msg = bot.send_message(message.chat.id, 'Введите ваше сообщение')
bot.register_next_step_handler(msg, getresults)
def getresults(message):
user_data['message'] = message.text
bot.send_message(message.chat.id, f"ФИО: {user_data['name']} \nТел: {user_data['phone']} \nПочта: {user_data['email']} \nСообщение: {user_data['message']}")
user_data
. It will be constantly overwritten. How can this be resolved?
Answer the question
In order to leave comments, you need to log in
Can. Create a database using user id as a key.
See the sqlite3 module , and SQL basics . Just to understand what you're doing.
If you can’t master the database, then you can write everything into text books, and call them by user id
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question