【发布时间】:2018-11-04 08:54:26
【问题描述】:
我在 Telegram bot 中使用处理程序。一旦他们使用该命令,我需要在其中获取用户名或用户 ID。
我的代码
import telebot #Telegram Bot API
bot = telebot.TeleBot(<BotToken>)
@bot.message_handler(commands=['info'])
def send_welcome(message):
name = bot.get_me()
print(name)
bot.reply_to(message, "Welcome")
bot.polling()
但是,我只获得有关该机器人的信息。我无法检索有关使用处理程序的用户的信息。
输出
{'first_name': 'SPIOTSYSTEMS', 'id': 581614234, 'username': 'spiotsystems_bot', 'is_bot': True, 'last_name': None, 'language_code': None}
如何获取使用info 命令的人的用户ID 或姓名?
我将使用哪种方法?请指教。
注意:
我的机器人与 Telegram 群组相关联。并且出于安全原因,我已从 MVC 中删除了 Telegram TOKEN。
【问题讨论】:
标签: python python-3.x telegram telegram-bot python-telegram-bot