Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/362.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/python-2.7/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用telethon获取关于或描述的电报机器人_Python_Telethon - Fatal编程技术网

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

Python 如何使用telethon获取关于或描述的电报机器人,python,telethon,Python,Telethon,当我通过bot获取历史聊天消息时,我在返回消息上下文中看不到“hello”消息(“这个bot可以做什么?”)。我怎样才能得到它 message_context = client.send_message(bot_name, '/start') for message in client.iter_messages(bot_name): print("{}".format(bot_name)) 您需要使用获取实例的属性: from telethon.sync import Telegram

当我通过bot获取历史聊天消息时,我在返回消息上下文中看不到“hello”消息(“这个bot可以做什么?”)。我怎样才能得到它

message_context = client.send_message(bot_name, '/start')
for message in client.iter_messages(bot_name):
   print("{}".format(bot_name))
您需要使用获取实例的属性:

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)