一个机器人向我转发了一些媒体文件,但我无法从机器人聊天下载媒体。没有错误,也没有日志警告/message。这只是崩溃。我通常使用download_media((没有任何困难,但这是我第一次尝试从机器人聊天下载,请给我任何建议,
没有错误
#!/usr/bin/env python3.9
import asyncio
from telethon import TelegramClient
from telethon import errors
import logging
logging.basicConfig(level=logging.DEBUG)
logging.getLogger('telethon').setLevel(level=logging.DEBUG)
async def login(client, phone):
print("Start...")
await client.connect()
if not await client.is_user_authorized():
print("Requesting auth..")
await client.send_code_request(phone)
await client.sign_in(phone, int(input('Enter code: ')))
try:
async with client.takeout(finalize=False) as takeout:
print("Connected...")
return takeout
except errors.TakeoutInitDelayError:
print("Please confirm and restart (+42777)")
return False
async def start((:
api_id =
api_hash =
tel =
client = TelegramClient('test', api_id, api_hash)
takeout = await login(client, tel)
if not takeout:
loop.stop()
channel = await takeout.get_input_entity('https://t.me/xxxxx_Bot')
msgs = await takeout.get_messages(channel) # get message object
print(msgs) # print message OK
await client.download_media(msgs) # has no effect , no error or log strings
loop.stop()
loop = asyncio.get_event_loop()
try:
task_start = loop.create_task(start())
loop.run_forever()
except KeyboardInterrupt:
pass
finally:
pass
如何从机器人聊天下载媒体?感谢
代码没有错误。
msgs = await takeout.get_messages(channel)
get_messages((只获取已读消息。。。。