beta-tgdrive / session.py
dragxd's picture
deleted session
7139588
from pathlib import Path
from pyrogram import Client
# Ask for data interactively
API_ID = int(input("Enter API_ID: ").strip())
API_HASH = input("Enter API_HASH: ").strip()
BOT_TOKEN = input("Enter BOT_TOKEN: ").strip()
# Session name (file will be <session_name>.session)
session_name = input("Enter session name (e.g. bot1): ").strip() or "bot1"
# Optional: put sessions into ./cache like TGDrive does
session_dir = Path("./cache")
session_dir.mkdir(parents=True, exist_ok=True)
async def main():
print("\n>>> Starting bot once to create session file...")
async with Client(
name=session_name,
api_id=API_ID,
api_hash=API_HASH,
bot_token=BOT_TOKEN,
workdir=session_dir,
ipv6=False,
) as app:
me = await app.get_me()
print(f"Logged in as bot: @{me.username} (id: {me.id})")
print(f"\n✅ Session file created at: {session_dir / (session_name + '.session')}")
print("Now you can use this name in BOT_SESSIONS.")
if __name__ == "__main__":
import asyncio
asyncio.run(main())