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.
| 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. |
┌──────────────┐ ┌───────────────────────┐ ┌──────────────────────────────────┐
│ │ /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 └───────────────────┘ └───────────────────┘
- Bot Layer (
aiogram): Handles user interactions, commands, keyboard actions, countdown timers, and UI message cleanups. - Auth Layer (
Pyrogram/Telethon): Ephemerally instantiated only when logging into MTProto, exporting the session string, and immediately disconnecting.
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
- Python 3.11+
- A Bot Token from @BotFather
- Default
API_ID&API_HASHfrom my.telegram.org/apps
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) |
- Push this repository to your GitHub account.
- Go to Railway
$\rightarrow$ New Project$\rightarrow$ Deploy from GitHub repo. - Under Variables, add your
BOT_TOKEN,API_ID, andAPI_HASH. - 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.
# Clone repository
git clone <your-repo-url>
cd Session-gen
# Configure environment
cp .env.example .env
# Build and run
docker compose up -d --build# Install dependencies
pip install -r requirements.txt
# Run bot
python main.py[ /start ] ──► [ ⚡ Generate Session ] ──► Choose Library (Pyrogram / Telethon)
│
▼
[ Receive String ] ◄── [ Enter 2FA Password ] ◄── [ Enter Code ] ◄── [ Enter Phone ]
- Send
/startand tap ⚡ Generate Session. - Select your framework: Pyrogram or Telethon.
- Choose credentials: Default API Credentials or Use My Own.
- Input your phone number, verification code, and 2FA password (if enabled).
- 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.
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.
- Edge Deployment Exploration: Potential Cloudflare Workers port (requiring a GramJS / Durable Objects implementation for MTProto compatibility).
- 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
LICENSEfor more information.