from telethon import TelegramClient
from config import config
client = TelegramClient(config.SESSION_NAME, config.TG_API_ID, config.TG_API_HASH)
async def main(img_path=None):
async for dialog in client.iter_dialogs():
if dialog.is_channel:
if dialog.id == -123456789:
print(f'{dialog.id}: {dialog.title}')
channel_from = dialog
messages = await client.get_messages(channel_from, limit=None)
for message in messages:
if message.file:
path = await client.download_media(message.media, "/tmp/output")
print(f'File saved to {path}') # printed after download is done