V
V
VeinKoor2022-01-16 09:11:39
In contact with
VeinKoor, 2022-01-16 09:11:39

Vk_bottle How to write a user's message to a certain variable and save it?

I need the bot to ask the person for a name, and save it, and with a certain command, he sends the same name to the person. The main thing is that the name is taken not from the user profile, but exactly the one that he indicated.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Renat Ataev, 2022-01-16
@fanepka

name = ''

@bot.on.private_message(text = 'ввести_имя')
async def get_name(message):
    global name
    name = message.text


@bot.on.private_message(text = 'мое_имя')
async def get_name(message):
    global name
    await message.answer(f"Ваше имя:  {name}")

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question