Skip to content

Instantly share code, notes, and snippets.

@wotori
Created August 18, 2025 14:10
Show Gist options
  • Select an option

  • Save wotori/f25af1b555579ff2ab0e518da474041a to your computer and use it in GitHub Desktop.

Select an option

Save wotori/f25af1b555579ff2ab0e518da474041a to your computer and use it in GitHub Desktop.
from telethon import TelegramClient
from telethon.sessions import StringSession
API_ID = int(input("API_ID: "))
API_HASH = input("API_HASH: ")
with TelegramClient(StringSession(), API_ID, API_HASH) as client:
print("STRING_SESSION=", client.session.save())
@wotori
Copy link
Author

wotori commented Aug 18, 2025

import asyncio
from telethon import TelegramClient
from telethon.sessions import StringSession

API_ID = int(input("API_ID: "))
API_HASH = input("API_HASH: "))

async def main():
async with TelegramClient(StringSession(), API_ID, API_HASH) as client:
print("STRING_SESSION=", client.session.save())

if name == "main":
asyncio.run(main())

@wotori
Copy link
Author

wotori commented Aug 18, 2025

import asyncio
from telethon import TelegramClient
from telethon.sessions import StringSession

API_ID = int(input("API_ID: "))
API_HASH = input("API_HASH: "))

async def main():
    async with TelegramClient(StringSession(), API_ID, API_HASH) as client:
        print("STRING_SESSION=", client.session.save())

if __name__ == "__main__":
    asyncio.run(main())

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment