Z
Z
zhmerin2020-01-16 16:13:59
Telegram
zhmerin, 2020-01-16 16:13:59

How to get username of telebot user?

Hi, I need to get the username of the user who is talking to the bot, but instead,
c.message.from_user.username returns the bot's username to me. Any ideas how to get the username of a user?

@bot.callback_query_handler(func=lambda c:True)
def inline(c):
  if c.data == "Tokyo":
    key = types.InlineKeyboardMarkup()
    but_1 = types.InlineKeyboardButton(text="170 UAH.", callback_data="170 UAH.")
    but_2 = types.InlineKeyboardButton(text="340 UAH.", callback_data="340 UAH.")
    key.add(but_1, but_2)
    bot.edit_message_text(chat_id = c.message.chat.id, message_id = c.message.message_id, text = c.message.text.replace("one",two), reply_markup=key)
  if c.data in osaka:
    myname = c.message.from_user.username
    bot.send_message('тут айди чата', myname)

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question