This module is small util for converting Telegram sessions to various formats (Telethon, Pyrogram, Tdata)
$ pip install TGSessionsCoverter
- in the first step: Converting your format to a TelegramSession instance
from tg_converter import TelegramSession
import io
API_ID = 123
API_HASH = "Your API HASH"
# From SQLite telethon\pyrogram session file
session = TelegramSession.from_sqlite_session_file("my_session_file.session", API_ID, API_HASH)
# From SQLite telethon\pyrogram session file bytes stream (io.BytesIO)
with open("my_example_file.session", "rb") as file:
session_stream = io.BytesIO(file.read())
session = TelegramSession.from_telethon_sqlite_stream(session_stream, API_ID, API_HASH)
- Converting TelegramSession instance to the format whats you need
from tg_converter import TelegramSession
session = TelegramSession(...) # See first step to learn how to create from various formats
# To telethon client
client = session.make_telethon(sync=True) # Use MemorySession as default, see docs
client.connect()
client.send_message("me", "Hello, World!")
client.disconnect()
# To telethon session file (SQLite)
session.make_telethon_session_file("telethon.session")
...
- From telethon\pyrogram SQLite session file
- From telethon\pyrogram SQLite session stream
- From tdata
- To telethon client object (Sync\Async)
- To telethon SQLite session file
- To pyrogram client object
- To pyrogram SQLite session file
- To tdata