31 lines
795 B
Python
31 lines
795 B
Python
import sys
|
|
from pathlib import Path
|
|
|
|
try:
|
|
from TGConvertor import SessionManager
|
|
except Exception as exc:
|
|
print(f"ERROR: TGConvertor not available: {exc}")
|
|
sys.exit(2)
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
print("ERROR: tdata path is required")
|
|
sys.exit(2)
|
|
tdata_path = Path(sys.argv[1]).expanduser().resolve()
|
|
if not tdata_path.exists():
|
|
print("ERROR: tdata path does not exist")
|
|
sys.exit(2)
|
|
|
|
session = SessionManager.from_tdata_folder(tdata_path)
|
|
# Convert to Telethon string for GramJS compatibility
|
|
from TGConvertor.sessions.tele import TeleSession
|
|
|
|
tele = TeleSession(dc_id=session.dc_id, auth_key=session.auth_key)
|
|
session_string = tele.to_string()
|
|
print(session_string)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|