Skip to content

About

A simple Telegram session generator bot that lets users generate Pyrogram and Telethon session strings quickly and easily. Built for convenient, secure, and hassle-free Telegram client authentication.

Resources

Stars

1 star

Watchers

0 watching

Forks

Repository files navigation

⚡ Telegram Session Generator Bot

Python aiogram Docker Railway License: MIT

A secure, zero-persistence Telegram bot that generates Pyrogram and Telethon session strings instantly — nothing stored, nothing logged, nothing sent anywhere except back to you.


🌟 Highlights & Features

Feature Description
🧪 Two Flavors Full support for both Pyrogram and Telethon string generations.
🔑 Credential Modes Use default system API credentials or supply your own personal API_ID/API_HASH.
🔒 Zero Persistence No databases, no disk logs, no credentials saved. Everything lives in ephemeral RAM.
🧹 Self-Cleaning Chat Auto-deletes user input (phone, codes, passwords) immediately after reading.
⏱️ Idle Timeout Smart 5-minute timeout per step with active countdown warnings at 60s, 30s, and 10s.
🎨 Animated UI Seamless inline-keyboard workflow accompanied by message effects (🔥 / 🎉).
🐳 Container-Ready Optimized for zero-config Docker deployments and 1-click Railway hosting.

🔄 How It Works

┌──────────────┐          ┌───────────────────────┐          ┌──────────────────────────────────┐
│                │  /start  │                            │  Login   │                                        │
│ User Chat      ├────────►│ Bot Layer (aiogram)       ├────────►│ Auth Layer (Pyrogram / Telethon)       │
│                │           │ (UI & Control Flow)       │  Step    │ (MTProto Client Interface)             │
└──────┬───────┘          └───────────┬───────────┘          └─────────────────┬────────────────┘
       │                                   │                                             │
       │                                   ▼                                            ▼
       │                    ┌───────────────────┐                    ┌───────────────────┐
       │                    │ Ephemeral Memoryh     │                    │ Official Telegram    │
       └──────── ────────┤ (In-RAM State)        │                    │ MTProto Servers      │
          Recovers String   └───────────────────┘                    └───────────────────┘
  1. Bot Layer (aiogram): Handles user interactions, commands, keyboard actions, countdown timers, and UI message cleanups.
  2. Auth Layer (Pyrogram/Telethon): Ephemerally instantiated only when logging into MTProto, exporting the session string, and immediately disconnecting.

📁 Repository Structure

Session-gen/
├── 📄 main.py               # Entry point: aiogram bot routing, flow control, & effects
├── 📄 session_manager.py     # Memory state, countdown timers, panel tracking
├── 📄 flavors.py             # SDK Adapters for Pyrogram & Telethon client connections
├── 📄 ui.py                  # UI layout, keyboards, fonts, and message text templates
├── 📄 config.py               # Environment configuration loader
├── 📋 requirements.txt       # Python dependencies
├── 🐳 Dockerfile             # Container build recipe
├── 🐙 docker-compose.yml     # Local deployment orchestration
└── ⚙️ .env.example          # Sample environment variables template

🚀 Quick Start & Deployment

Prerequisites


⚙️ Environment Variables

Copy .env.example to .env and configure your environment:

cp .env.example .env
Variable Required Default Description
BOT_TOKEN Yes — Bot token received from @BotFather
API_ID Yes — Default numeric Telegram API ID
API_HASH Yes — Default Telegram API Hash
ADMIN_IDS No None Comma-separated user IDs (reserved for administrative utilities)
FLOW_TIMEOUT_SECONDS No 300 Idle timeout per step (minimum recommended: 60)

🚂 Deploy to Railway

  1. Push this repository to your GitHub account.
  2. Go to Railway $\rightarrow$ New Project $\rightarrow$ Deploy from GitHub repo.
  3. Under Variables, add your BOT_TOKEN, API_ID, and API_HASH.
  4. Deploy! Check Deploy Logs for Starting bot....

Note

Railway operates using polling (no open ports needed). On free/hobby tiers, container restarts will wipe active state; users mid-flow will simply need to click Generate again.


🐳 Local Deployment (Docker or Python)

Option A: Docker Compose (Recommended)

# Clone repository
git clone <your-repo-url>
cd Session-gen

# Configure environment
cp .env.example .env

# Build and run
docker compose up -d --build

Option B: Direct Python Execution

# Install dependencies
pip install -r requirements.txt

# Run bot
python main.py

📱 User Workflow

[ /start ] ──► [ ⚡ Generate Session ] ──► Choose Library (Pyrogram / Telethon)
                                                  │
                                                  ▼
[ Receive String ] ◄── [ Enter 2FA Password ] ◄── [ Enter Code ] ◄── [ Enter Phone ]
  1. Send /start and tap ⚡ Generate Session.
  2. Select your framework: Pyrogram or Telethon.
  3. Choose credentials: Default API Credentials or Use My Own.
  4. Input your phone number, verification code, and 2FA password (if enabled).
  5. Receive your session string instantly!

Tip

You can tap ✕ Cancel at any point during the process to instantly abort the flow and sever open client connections.


🛡️ Security & Privacy Architecture

Important

Your credentials and account safety are top priorities. The repository is audited to ensure no sensitive actions take place without user consent.

  • Zero Database / Disk Writes: All variables, phone numbers, codes, and temporary client objects are held strictly in temporary RAM (dict) and destroyed immediately after completion or cancellation.
  • Auto-Clearing Chat: Sensitive user messages (phone numbers, OTP login codes, 2FA passwords, API details) are deleted from Telegram chat history right after processing.
  • No Hidden Side-Effects: This bot performs no auto-joins, no channels/group subs, and no background actions. It authenticates, exports the string, and disconnects.

Warning

Treat your Session String like a Password!
Anyone with access to your session string gains access to your account. Store it strictly in secret managers or environment variables—never share or post it publicly.


🛣️ Roadmap

  • Edge Deployment Exploration: Potential Cloudflare Workers port (requiring a GramJS / Durable Objects implementation for MTProto compatibility).

📄 Disclaimer & License

  • Disclaimer: This tool is designed strictly for developers generating session strings for their own accounts. Do not deploy modified instances intended to secretly store, forward, or utilize user session keys without explicit permission.
  • License: Distributed under the MIT License. See LICENSE for more information.

About

A simple Telegram session generator bot that lets users generate Pyrogram and Telethon session strings quickly and easily. Built for convenient, secure, and hassle-free Telegram client authentication.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages