feat(auth): add interactive login script for userbot session creation
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import os
|
||||
import asyncio
|
||||
from telethon import TelegramClient
|
||||
from dotenv import load_dotenv
|
||||
|
||||
load_dotenv()
|
||||
|
||||
API_ID = int(os.getenv("API_ID", "0"))
|
||||
API_HASH = os.getenv("API_HASH", "")
|
||||
PHONE = os.getenv("PHONE")
|
||||
SESSION_NAME = os.getenv("SESSION_NAME", "/projects/telegram-bots/copykar/sessions/collector.session")
|
||||
|
||||
from core.proxy import get_telegram_proxy
|
||||
|
||||
async def main():
|
||||
os.makedirs(os.path.dirname(SESSION_NAME), exist_ok=True)
|
||||
proxy = get_telegram_proxy()
|
||||
print(f"Connecting to Telegram for {PHONE}...")
|
||||
client = TelegramClient(SESSION_NAME, API_ID, API_HASH, proxy=proxy)
|
||||
await client.start(phone=PHONE)
|
||||
me = await client.get_me()
|
||||
print(f"✅ Success! Logged in as: {me.first_name} (@{me.username}) [ID: {me.id}]")
|
||||
print(f"Session saved to: {SESSION_NAME}")
|
||||
await client.disconnect()
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
Reference in New Issue
Block a user