A bot forward to me some media file but I can't download media from bot chat. No errors and no log warning/message.It crash only. I usually use download_media() with no difficulty, but this is the first time I try to download from bot chat please any advice ,
There are no errors
#!/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
How to download media from bot chat ? thank
The code has no fault.
msgs = await takeout.get_messages(channel)
get_messages() only gets read messages....