I’m developing a Telegram bot that uses a handler to respond to commands. My goal is to capture either the user’s name or their ID when they execute a specific command.
MY CODE
import telebot # Telegram Bot API
bot = telebot.TeleBot(<YourBotToken>)
@bot.message_handler(commands=['details'])
def greet_user(message):
user_info = message.from_user # Access user details
print(user_info)
bot.reply_to(message, 'Hello!')
bot.polling()
Currently, the information retrieved pertains only to the bot itself. How can I access the details of the user triggering the handler? What method should I implement to achieve this?
NOTE:
My bot has been integrated with a Telegram group, and I’ve ensured to safeguard my Telegram Token within my MVC.