Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Session Generator Bot

A secure Telegram bot that generates Pyrogram and Telethon session strings for users. This bot helps users create session strings safely and securely for their Telegram accounts.

Features

  • 🎨 Kurigram Bot API 10.2 UI: Native Rich Messages, HTML tables, collapsible <details>, styled buttons, and streaming drafts
  • 🔐 Secure Session Generation: Safely generates Pyrogram and Telethon session strings
  • 🧩 Both Libraries: Pick Pyrogram or Telethon with styled inline buttons
  • 📱 Phone Number Verification: Supports international phone number format
  • 🔢 2FA Support: Handles two-factor authentication with in-memory security
  • Fast & Reliable: Live streaming draft updates during authorization
  • 🛡️ Privacy Focused: Keeps user data secure and isolated
  • 🐳 Docker Ready: Easy deployment with Docker

Prerequisites

  • Python 3.8+
  • Telegram Bot Token
  • Telegram API ID and API Hash

Installation

Using Docker (Recommended)

  1. Clone the repository:
git clone https://github.com/nub-coders/Session-gen.git
cd Session-gen
  1. Build the Docker image:
docker build -t session .
  1. Run the container with restart policy:
docker run -d --name session --restart always session

Note: The --restart always flag ensures the container automatically restarts if it stops unexpectedly.

Manual Installation

  1. Install system dependencies:
sudo apt-get update
sudo apt-get install ffmpeg libmagic1
  1. Install Python dependencies:
pip install -r requirements.txt
  1. Configure your bot:

    • Copy .env.example to .env and fill in your values
    • Set ADMIN_IDS (comma-separated user IDs) in .env if needed
  2. Run the bot:

python main.py

Configuration

Set up your environment variables in .env:

API_ID=your_api_id
API_HASH=your_api_hash
BOT_TOKEN=your_bot_token
GROUP=your_support_group
CHANNEL=your_updates_channel
ADMIN_IDS=123456789,987654321

Getting API Credentials

  1. Go to my.telegram.org
  2. Log in with your phone number
  3. Go to "API development tools"
  4. Create a new application
  5. Copy your API ID and API Hash

Getting Bot Token

  1. Message @BotFather on Telegram
  2. Create a new bot with /newbot
  3. Copy the bot token

Usage

Bot Commands

  • /start - Show welcome message and bot information
  • /gen - Generate a session string (choose Pyrogram or Telethon)

Generating Session Strings

  1. Start a conversation with the bot
  2. Send /gen command
  3. Choose Pyrogram or Telethon
  4. Enter your phone number in international format (e.g., +1234567890)
  5. Enter the verification code sent to your Telegram
  6. If 2FA is enabled, enter your password
  7. Receive your session string

Tap ❌ Cancel at any step to abort the flow.

Security Features

  • Non-root User: Docker container runs as non-root user
  • Session Isolation: Each user session is isolated
  • Input Validation: Phone numbers and codes are validated
  • Error Handling: Comprehensive error handling for various scenarios
  • Admin Controls: Restricted admin commands

Project Structure

Session-gen/
├── main.py              # Main bot application (kurigram/pyrogram, state-machine flow)
├── flavors.py           # Pyrogram/Telethon adapters + error classes
├── config.py            # Configuration file
├── requirements.txt     # Python dependencies
├── .env.example         # Example environment variables template
├── Dockerfile          # Docker configuration
└── README.md           # This file

Dependencies

  • Pyrogram (kurigram): Bot client and Pyrogram session generation
  • Telethon: Telethon session generation
  • And more: See requirements.txt for complete list

Docker Configuration

The Dockerfile includes:

  • Latest Python image
  • System dependencies (ffmpeg, libmagic)
  • Security hardening (non-root user)
  • Optimized layer caching
  • Environment variables

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Test thoroughly
  5. Submit a pull request

Support

License

This project is licensed under the MIT License - see the LICENSE file for details.

Disclaimer

⚠️ Important: Never share your session strings with anyone! They provide full access to your Telegram account. This bot is for educational and legitimate use only.

Changelog

  • v2.1.0: Full migration to Kurigram Bot API 10.2 UI — Native Rich Messages (send_rich_message), interactive HTML <table> layouts, collapsible <details> walkthroughs, ButtonStyle inline buttons, streaming drafts (send_rich_message_draft) for real-time progress, and ephemeral feedback toasts.
  • v2.0.0: Added Telethon session generation via /gen → inline button choice; state-machine flow (conversation-lite) replaces telethon's Conversation API; cancel button, code-expiry handling, client cleanup on every exit path; kurigram/pyrogram bot
  • v1.0.0: Initial release with Pyrogram session generation

Made with ❤️ by @nub_coder_s

About

A secure Telegram bot that generates Pyrogram session strings with 2FA support, phone verification, and Docker-ready deployment.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages