Search code examples
pythonbuttontelegraminlinetelegram-bot

How to know which user pressed button


I am making Telegram Bot and I have two inline buttons. I need to do that when the user clicks on a button bot would answer like "Hi @username". How to do that?


Solution

  • I found a way to do this! You need to add username = "@" + str(message.from_user.username) and then bot.send_message(message.chat.id, "Hi " + username)