如何使用telethon获取有关或描述的电报机器人

2024-03-29 10:01:15 发布

您现在位置:Python中文网/ 问答频道 /正文

当我收到一个机器人的历史聊天信息时,我看不到“hello”信息(“这个机器人能做什么?”)在返回消息上下文中。我怎样才能得到它?你知道吗

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

Tags: nameinclientsend信息消息messagehello
1条回答
网友
1楼 · 发布于 2024-03-29 10:01:15

您需要使用^{}来获取^{}实例的^{}属性:

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)

相关问题 更多 >