如何使用Telethon获取有关Telegram机器人或其描述的信息

时间:2019-07-18 13:05:49

标签: python telethon

当我通过漫游器收到历史聊天消息时,在返回message_context中看不到“ hello”消息(“此漫游器能做什么?”)。我怎么能得到它?

message_context = client.send_message(bot_name, '/start')
for message in client.iter_messages(bot_name):
   print("{}".format(bot_name))

1 个答案:

答案 0 :(得分:3)

您需要使用GetFullUserRequest来获取bot_info实例的UserFull属性:

from telethon.sync import TelegramClient
from telethon import functions, types

with TelegramClient(name, api_id, api_hash) as client:
    result = client(functions.users.GetFullUserRequest(bot_name))
    bot_info = result.bot_info
    print(bot_info)
    print(bot_info.description)