Skip to content

Instantly share code, notes, and snippets.

@hugmouse
Created August 13, 2023 15:16
Show Gist options
  • Save hugmouse/41e29937f11e9b3c989f1af36f319c2d to your computer and use it in GitHub Desktop.
Save hugmouse/41e29937f11e9b3c989f1af36f319c2d to your computer and use it in GitHub Desktop.
Just iterates over your dialogs in Telegram and prints the name of the dialog and it's ID
import asyncio
from pyrogram import Client
# Replace with your API credentials
api_id = 1
api_hash = '1'
async def main():
async with Client("chat_iterator", api_id, api_hash) as app:
async for dialog in app.get_dialogs():
print(dialog.chat.title or dialog.chat.first_name, dialog.chat.id)
asyncio.run(main())
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment