Phase 0 MVP: Telegram Archiver fully functional (992 posts tested)

This commit is contained in:
2026-03-06 22:15:50 +03:00
parent bb8c7766b4
commit b76e27afcb
14 changed files with 1171 additions and 134 deletions
+71
View File
@@ -0,0 +1,71 @@
#!/usr/bin/env python
"""
Login script using Pyrogram as fallback when Telethon fails.
Pyrogram sometimes works when Telethon is blocked.
"""
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))
os.chdir(project_root)
from pyrogram import Client
import asyncio
import configparser
async def login():
"""Interactive login using Pyrogram."""
print("\n" + "=" * 60)
print("TELEGRAM ARCHIVER - PYROGRAM AUTHENTICATION")
print("=" * 60)
# Parse .env manually
env_vars = {}
with open('.env', 'r') as f:
for line in f:
line = line.strip()
if line and not line.startswith('#') and '=' in line:
key, value = line.split('=', 1)
env_vars[key.strip()] = value.strip()
api_id = int(env_vars.get('API_ID', 0))
api_hash = env_vars.get('API_HASH', '')
phone = env_vars.get('PHONE', '')
print(f"\nPhone: {phone}")
print(f"API ID: {api_id}")
print("=" * 60)
print("\nTelegram will send you a code via SMS automatically")
print("if the app code is not available.")
print("=" * 60)
# Create Pyrogram client
app = Client(
name="pyrogram-session",
api_id=api_id,
api_hash=api_hash,
phone_number=phone,
workdir=project_root
)
async with app:
print("\nSuccessfully logged in!")
print(f"Session saved to: {project_root / 'pyrogram-session.session'}")
# Get me info
me = await app.get_me()
print(f"\nLogged in as: {me.first_name} @{me.username}")
print(f"User ID: {me.id}")
if me.username:
print(f"\nYou can now archive your channel: @{me.username}")
print("\n" + "=" * 60)
if __name__ == "__main__":
asyncio.run(login())