F
F
fergios2020-07-21 14:32:11
Python
fergios, 2020-07-21 14:32:11

I can't display the user's nickname in the bot?

They wrote me a bot to order, I want it to display not only the Name + Text, but also the user's Nickname, if it is installed. It’s just that when a nickname is written in a message from a bot, he receives a notification that you were mentioned in the chat, and if just a name is written, then nothing comes. My programmer is out of touch. Help me please.

"""Если пользователя нет в списке, то отправляет сообщение 'имя + текст' из файла message.txt. """
        text = get_message()  # Получает сообщение из файла
        bot_message = await message.answer(text=f'{message.from_user.first_name}, {text}', parse_mode='HTML')

I tried that, but it doesn't work. It still displays only the username.

"""Если пользователя нет в списке, то отправляет сообщение 'имя + текст' из файла message.txt. """
        text = get_message()  # Получает сообщение из файла
        bot_message = await message.answer(text=f'{message.from_user.first_name},{message.from_user.username}, {text}', parse_mode='HTML')


By the way, I tried it like this, it also displays the Username for some reason. Replaced .first_name with .username
"""Если пользователя нет в списке, то отправляет сообщение 'имя + текст' из файла message.txt. """
        text = get_message()  # Получает сообщение из файла
        bot_message = await message.answer(text=f'{message.from_user.username}, {text}', parse_mode='HTML')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
soremix, 2020-07-21
@fergios

What does "doesn't bug" mean?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question