Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from pyrogram import Client
- from pyrogram.enums import ChatType
- client = Client('session_name', api_id, api_hash)
- async def get_owner_dialogs():
- async for d in client.get_dialogs():
- c = d.chat
- if c.is_creator and c.type in {ChatType.GROUP, ChatType.SUPERGROUP}:
- first = await client.get_messages(c.id, 1)
- if first.empty:
- oldest = await anext(
- client.get_chat_history(c.id, limit=1, offset_id=1, offset=-1), None
- )
- if oldest and not oldest.empty: first = oldest
- else: continue
- if not first.date.year < 2023: continue
- if c.username:
- link = f"https://t.me/{c.username}"
- else:
- link = (await client.get_chat(c.id)).invite_link
- await client.send_message(
- "me",
- f"{c.title} | {first.date.year} | {c.type.value.lower()}\n\n{link}",
- disable_web_page_preview=True,
- )
- client.start()
- client.run(get_owner_dialogs())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement