mirror of
https://gitverse.ru/kpa39l/chronicle.nixg.ru.git
synced 2026-09-29 18:05:07 +00:00
Phase 0 MVP: Telegram Archiver fully functional (992 posts tested)
This commit is contained in:
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
Interactive login script for Telegram Archiver with SMS fallback.
|
||||
|
||||
If you don't receive the code in the Telegram app, this script will
|
||||
offer to request an SMS instead.
|
||||
"""
|
||||
|
||||
import sys
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
# Add project root to path
|
||||
project_root = Path(__file__).parent
|
||||
sys.path.insert(0, str(project_root))
|
||||
|
||||
# Set working directory to project root for .env loading
|
||||
os.chdir(project_root)
|
||||
|
||||
from app.telethon_client import TelethonArchiver
|
||||
from config import get_settings
|
||||
from telethon.errors import SessionPasswordNeededError
|
||||
import asyncio
|
||||
|
||||
async def login():
|
||||
"""Interactive login to Telegram with SMS fallback."""
|
||||
settings = get_settings()
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
print("TELEGRAM ARCHIVER - AUTHENTICATION")
|
||||
print("=" * 60)
|
||||
print(f"Phone: {settings.phone}")
|
||||
print("=" * 60)
|
||||
|
||||
async with TelethonArchiver(settings) as client:
|
||||
print("\n✅ Successfully logged in!")
|
||||
print(f"📁 Session saved to: {settings.session_path}")
|
||||
|
||||
# Test by getting me info
|
||||
me = await client.client.get_me()
|
||||
print(f"\n👤 Logged in as: {me.first_name} @{me.username}")
|
||||
print(f" User ID: {me.id}")
|
||||
|
||||
if me.username:
|
||||
print(f"\n✅ You can now archive your channel: @{me.username}")
|
||||
|
||||
print("\n" + "=" * 60)
|
||||
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(login())
|
||||
Reference in New Issue
Block a user