Spaces:
Paused
Paused
Download generate_session.py from saske560/userbotsaskeds: direct link, hf CLI and curl.
- Browser
- Download file 1.32 kB
-
https://huggingface.co/spaces/saske560/userbotsaskeds/resolve/main/generate_session.py
- Command line
-
hf download hf://spaces/saske560/userbotsaskeds/generate_session.py
-
curl -L -o generate_session.py https://huggingface.co/spaces/saske560/userbotsaskeds/resolve/main/generate_session.py
1.32 kB
| """ | |
| generate_session.py — Ejecuta UNA VEZ en tu máquina local. | |
| Genera el SESSION_STRING para pegar en HF Spaces Secrets. | |
| Uso: | |
| pip install pyrogram tgcrypto | |
| python generate_session.py | |
| """ | |
| import asyncio | |
| from pyrogram import Client | |
| async def main(): | |
| print("=" * 58) | |
| print(" 🔑 Generador de Session String — TG UserBot") | |
| print("=" * 58) | |
| print() | |
| print(" Obtén API_ID y API_HASH en: https://my.telegram.org") | |
| print() | |
| api_id = int(input(" API_ID : ").strip()) | |
| api_hash = input(" API_HASH : ").strip() | |
| print() | |
| print(" Iniciando sesión con Telegram...") | |
| print(" (te pedirá tu número y el código de verificación)") | |
| print() | |
| async with Client( | |
| name="session_gen", | |
| api_id=api_id, | |
| api_hash=api_hash, | |
| in_memory=True, | |
| ) as client: | |
| session = await client.export_session_string() | |
| me = await client.get_me() | |
| print() | |
| print("=" * 58) | |
| print(f" ✅ Conectado como: {me.first_name} (ID: {me.id})") | |
| print("=" * 58) | |
| print() | |
| print(" SESSION_STRING:") | |
| print() | |
| print(session) | |
| print() | |
| print(" ⚠️ Copia el texto de arriba → HF Spaces Secrets") | |
| print(" ⚠️ NO lo compartas con nadie") | |
| print() | |
| if __name__ == "__main__": | |
| asyncio.run(main()) | |