Coding Python

Telegram Inviter Bot

0
Please log in or register to do it.

πŸ€– Telegram Inviter Bot is a professional tool for automatically inviting users from one Telegram group to another. It supports two operating modes, session rotation, flexible settings, and full control via the Telegram interface.

✨ Key Features πŸ”„ Inviting modes

  1. πŸ“‹ Participant list mode ( member_list) – recommended View the full list of members of the source group Inviting in sequential order Skipping already invited users Automatic continuation after restart
  2. πŸ’¬ Message mode ( message_based) Analysis of the source group’s message history Inviting message authors (active participants) Suitable for large groups with limited access to the participant list πŸ” Session Management Adding sessions : via CLI with interactive authorization Task assignment : link sessions to specific task types Session rotation : automatic switching when blocked Monitoring : status of all sessions in real time βš™οΈ Flexible settings Main parameters: Delay between invites : 1-300 seconds (30+ recommended) Delay frequency : after every Nth invite Invite Limit : The maximum number of invites per task. Session rotation : enable/disable Rotation frequency : after every Nth invite or only in case of errors Protection from blocking: Automatic FloodWait processing Skipping users with closed privacy Smart session rotation in case of critical errors Limits on the number of invites per hour/day

πŸ—οΈ Architecture

inviter/
β”œβ”€β”€ bot/                    # Telegram bot (management interface)
β”‚   β”œβ”€β”€ bot_main.py         # Main bot file
β”‚   β”œβ”€β”€ handlers.py         # Command and menu handlers
β”‚   β”œβ”€β”€ states.py           # FSM states and keyboards
β”‚   β”œβ”€β”€ session_handlers.py # Session management
β”‚   β”œβ”€β”€ api_client.py       # HTTP client for the API
β”‚   └── config.py           # Bot configuration
β”‚
β”œβ”€β”€ parser/                 # API server and worker (core)
β”‚   β”œβ”€β”€ main.py             # FastAPI application
β”‚   β”œβ”€β”€ inviter_worker.py   # Inviting logic
β”‚   β”œβ”€β”€ session_manager.py  # Session manager
β”‚   β”œβ”€β”€ database.py         # SQLite database
β”‚   β”œβ”€β”€ add_session.py      # CLI for adding sessions
β”‚   └── config.py           # Server configuration
β”‚
β”œβ”€β”€ shared/                 # Shared models
β”‚   └── models.py           # Dataclasses (SessionMeta, InviteTask)
β”‚
β”œβ”€β”€ sessions/               # .session files for Telegram
β”œβ”€β”€ *.bat                   # Startup scripts (Windows)
β”œβ”€β”€ start_parser.bat        # Start API server (Windows)
β”œβ”€β”€ start_bot.bat           # Start Telegram bot (Windows)
β”œβ”€β”€ add_session.bat         # Add session (Windows)
β”œβ”€β”€ pyproject.toml          # Dependencies and metadata
β”œβ”€β”€ .env.example            # Example configuration
└── README.md

πŸš€ Installation and launch

πŸ“‹ System requirements

  • PythonΒ : 3.8+ (3.11+ recommended)
  • RAMΒ : minimum 512MB
  • DiskΒ : minimum 100MB of free space
  • NetworkΒ : stable internet connection for using the Telegram API

πŸ“¦ Installing dependencies

Ubuntu/Debian (including WSL):

# Update packages
sudo apt update

# Install Python venv and pip
sudo apt install python3-venv python3-pip python3-dev

# For additional libraries (optional)
sudo apt install build-essential libssl-dev libffi-dev

CentOS/RHEL/Fedora:

# CentOS/RHEL
sudo yum install python3-devel python3-pip
# or for newer versions
sudo dnf install python3-devel python3-pip

# Fedora
sudo dnf install python3-devel python3-pip

macOS

# Installation via Homebrew (recommended)
brew install python3

# Or, upgrading an existing Python
brew upgrade python3

# Installing dependencies for compilation
brew install openssl readline sqlite3 xz zlib

Arch Linux:

sudo pacman -S python python-pip python-virtualenv

2. Cloning and preparation

# Navigate to the project directory
cd /path/to/project/inviter

# Create a virtual environment
python3 -m venv venv

# Activate the virtual environment

Activating the virtual environment

Windows (cmd/PowerShell):

venv\Scripts\activate

Windows (PowerShell):

venv\Scripts\Activate.ps1

Linux/Mac:

source venv/bin/activate

3. Installing dependencies

pip install -r requirements.txt

4. Solving problems with the virtual environment

If you get the error “ensurepip is not available” (WSL/Debian/Ubuntu):

# Install python3-venv
sudo apt install python3.8-venv  # or python3.10-venv, depending on your Python version

# Recreate the virtual environment
python3 -m venv venv

# Activate
source venv/bin/activate

If the virtual environment is not created:

# Check the Python version
python3 --version

# Install virtualenv as an alternative
pip3 install virtualenv
virtualenv venv
source venv/bin/activate

Problems installing dependencies in a virtual environment:

# Upgrade pip in the virtual environment
source venv/bin/activate
pip install --upgrade pip

# If you encounter compilation errors, install build dependencies
# Ubuntu/Debian:
sudo apt install build-essential python3-dev

# CentOS/RHEL:
sudo yum groupinstall "Development Tools"
sudo yum install python3-devel

# macOS:
brew install openssl readline sqlite3 xz zlib

βš™οΈ Configuration

1. Creating a configuration file

cp .env.example .env

2. Filling the .env file

# Telegram bot token (get from @BotFather)
BOT_TOKEN=1234567890:ABCdefGHIjklMNOpqrsTUVwxyz123456789

# Administrator IDs (comma-separated)
ADMIN_IDS=123456789,987654321

# API data for sessions (get from https://my.telegram.org)
API_ID=12345678
API_HASH=abcdef1234567890abcdef1234567890

# Port for the API server (default is 8001)
API_PORT=8001

# Path to the database (default is ./inviter.db)
DATABASE_PATH=./inviter.db

# Directory for sessions (default is ./sessions)
SESSIONS_DIR=./sessions

πŸ”‘ Getting API data

  1. Go toΒ https://my.telegram.org
  2. Log in with your phone number
  3. Go to theΒ API development tools section
  4. Create a new application
  5. CopyΒ api_idandapi_hash

πŸ€– Creating a bot

  1. WriteΒ @BotFatherΒ on Telegram
  2. Send a command/newbot
  3. Follow the instructions to create a bot.
  4. Copy the token and paste it intoΒ .envthe file

🎯 Launching the application

πŸ“‹ What do the scripts run:

  • start_parser.bat(Windows) β†’ Starting the FastAPI server for API (port 8001)
  • start_bot.bat(Windows) β†’ Launch Telegram bot for control
  • add_session.bat(Windows) β†’ Adding a Telegram Session Interactively

On Linux/Mac, the equivalent Python commands are used directly.

Windows

Option 1: Using .bat scripts (recommended)

# Run the API server (terminal 1)
.\start_parser.bat

# Run the bot (terminal 2)
.\start_bot.bat

Option 2: Manual launch with environment activation

# Terminal 1 - API Server
venv\Scripts\activate
python -m uvicorn parser.main:app --host 0.0.0.0 --port 8001 --reload

# Terminal 2 - Bot
venv\Scripts\activate
python -m bot.bot_main

Option 3: Manual launch without activation (if the virtual environment is already active)

# Terminal 1 - API Server
python -m uvicorn parser.main:app --host 0.0.0.0 --port 8001 --reload

# Terminal 2 - Bot
python -m bot.bot_main

Linux/Mac

Option 1: With a virtual environment (recommended)

# Terminal 1 - API Server
source venv/bin/activate
python -m uvicorn parser.main:app --host 0.0.0.0 --port 8001 --reload

# Terminal 2 - Bot
source venv/bin/activate
python -m bot.bot_main

Option 2: Loading environment variables from the .env file

# Terminal 1 - API Server
source venv/bin/activate
[ -f .env ] && export $(grep -v '^#' .env | xargs)
python -m uvicorn parser.main:app --host 0.0.0.0 --port 8001 --reload

# Terminal 2 - Bot
source venv/bin/activate
[ -f .env ] && export $(grep -v '^#' .env | xargs)
python -m bot.bot_main

🐳 Docker (optional)

# Build the image
docker build -t telegram-inviter .

# Run the container
docker run -p 8001:8001 -v $(pwd)/sessions:/app/sessions telegram-inviter

πŸ” Session Management

Adding a new session

Windows:

# Option 1: Via .bat script
.\add_session.bat

# Option 2: Manual execution
venv\Scripts\activate
python -m parser.add_session

Linux/Mac:

# Option 1: With a virtual environment
source venv/bin/activate
python -m parser.add_session

# Option 2: With loading environment variables
source venv/bin/activate
[ -f .env ] && export $(grep -v '^#' .env | xargs)
python -m parser.add_session

Adding process:

  1. Enter a session name (alias)
  2. Enter API ID
  3. Enter the Hash API
  4. Enter your phone number (+1234567890)
  5. Enter the confirmation code from Telegram
  6. If prompted, enter your two-factor authentication password.

Managing sessions via a bot

  1. Run the bot with the command/start
  2. Go to theΒ πŸ” Sessions section
  3. SelectΒ “Show Sessions”Β to view all sessions.
  4. SelectΒ “Assign Session”Β to manage the session:
    • πŸ‘₯ InvitingΒ – linking a session to inviting tasks
    • 🌐 Configure proxyΒ – setting up a proxy for a session
    • πŸ§ͺ Check proxyΒ – check proxy functionality
    • πŸ—‘οΈ Remove proxyΒ – removes a proxy from the session
    • πŸ“‹ Copy proxyΒ – copying proxies to other sessions

Setting up a proxy for sessions

Proxy format:

scheme://user:pass@host:port
scheme://host:port

Checking the connection:

  • After setting up the proxy, use theΒ πŸ§ͺ Check proxy button
  • The system will check the connection both with and without a proxy.
  • In case of an error, a detailed description of the problem will be displayed.

πŸ‘₯ Using the bot

Basic workflow

  1. Launching the bot
    • Open the bot in Telegram
    • Send a command/start
  2. Setting up sessions
    • Go toΒ πŸ” Sessions
    • Add at least one session via CLI
    • Assign a session to the “Inviting” task
  3. Creating an inviting task
    • Go toΒ πŸ‘₯ Inviting
    • SelectΒ the source groupΒ (where to get users from)
    • SelectΒ the target groupΒ (where to invite)
    • SelectΒ operating modeΒ :
      • πŸ“‹Β By participant listΒ (recommended)
      • πŸ’¬Β According to reports
    • Adjust the settings

Invitation settings

πŸ“‹ “By Participant List” mode

β€’ Source group: must be readable for the member list
β€’ Target group: the bot must have administrator rights to invite
β€’ Recommended for groups up to 10,000 members

πŸ’¬ “By Message” mode

β€’ Analyzes recent group messages
β€’ Invites only active participants (message authors)
β€’ Suitable for large groups with limited access to the member list
β€’ May operate slower, but more safely

Setting options:

  • Delay between invitesΒ : 30-60 seconds (minimum!)
  • Delay frequencyΒ : after each invite
  • Invite LimitΒ : Set a reasonable limit
  • Session rotationΒ : enable for reliability
  • Rotation frequencyΒ : after 10-20 invites or only in case of errors

Task monitoring

  • Go toΒ πŸ“Š Task Status
  • View active, completed, and failed tasks
  • For active tasks: pause/resume/stop

πŸ“Š Bot commands

Basic commands:

  • /start– Main menu and getting started
  • /sessions– Session management (administrators only)
  • /status– View the status of all tasks

Navigation menu:

  • 🏠 Main menuΒ – section navigation
  • πŸ‘₯ InvitingΒ – creating and configuring tasks
  • πŸ“Š Task statusΒ – monitoring execution
  • πŸ” SessionsΒ – Managing Telegram sessions

πŸ›‘οΈ Safety and Security

⚠️Important Warnings

Telegram restrictions:

  • FloodWaitΒ : No more than 50 invitations per hour from one session
  • LimitsΒ : Maximum 100 invitations per day per account
  • BlockingΒ : Violating the rules may result in account blocking.

Safety recommendations:

  • UseΒ multiple sessionsΒ to distribute the load
  • SetΒ long delaysΒ (30-60 seconds minimum)
  • Do not exceedΒ 50 invitations per hourΒ per session.
  • Monitor task statusΒ regularly
  • UseΒ session rotationΒ to automatically switch

πŸ”„ Session rotation

Operating principle:

  1. Automatic switchingΒ during FloodWait or critical errors
  2. Checking accessΒ to groups before switching
  3. Excluding problematic sessionsΒ from the current task
  4. Continue workingΒ in a new session without losing progress

Rotation settings:

  • DisabledΒ : The session runs until it is completely blocked.
  • Only on errorsΒ : Switch to FloodWait/blocking only
  • After N invitesΒ : forced rotation every N invites

πŸ“ˆ Statistics and monitoring

Tracked metrics:

  • Number of successful invitations
  • Failure and error rate
  • Task execution time
  • Status of each session

Notifications:

  • Successful completionΒ of the task
  • Critical errorsΒ with a description of the problem
  • RotationΒ warnings
  • Session statusΒ in case of problems

πŸ”§ Troubleshooting

Common problems

❌ “ChannelPrivate” error

Problem: Cannot access private group
Solution: Ensure the session is a member of the group

❌ FloodWait

Problem: Request limit exceeded
Solution: Increase delay, enable session rotation

❌ “Admin rights required”

Problem: Bot cannot invite to the target group.
Solution: Grant the session administrator privileges with invitation rights.

❌ The session does not see participants

Problem: Participant list hidden for non-administrators
Solution: Use "By Message" mode or assign an administrator

Logs and debugging

View logs:

# API server logs
tail -f parser.log

# Bot logs
tail -f bot.log

Logging levels:

  • INFO: Main events and statuses
  • WARNING: Problem Warnings
  • ERROR: Critical errors
  • DEBUG: Detailed information for debugging

Disaster recovery

Force stop tasks:

# Via API
curl -X POST http://localhost:8001/tasks/{task_id}/stop

# Or via the bot in the task status menu

Cleaning the database:

```text
# Delete all tasks
rm inviter.db
# Restart the application
```

πŸŽ›οΈ Additional features

History of groups

  • Automatic saving of recently used groups
  • Quick selection from history when creating new tasks
  • Maximum 10 groups per user

Task management

  • Pause/resumeΒ active tasks
  • StoppingΒ while saving progress
  • View the historyΒ of all completed tasks
  • Export statisticsΒ in a convenient format

Notification system

  • Telegram notificationsΒ about important events
  • Real-timeΒ task status
  • Session ProblemΒ Warnings
  • CompletionΒ reports

πŸ“ API documentation

REST API endpoints:

Sessions:

  • GET /sessions– list of all sessions
  • POST /sessions/add– add a session
  • DELETE /sessions/{alias}– delete session

Tasks:

  • GET /tasks– user task list
  • POST /tasks– create a task
  • GET /tasks/{id}– task status
  • POST /tasks/{id}/start– run the task
  • POST /tasks/{id}/stop– stop the task

Groups:

  • GET /groups/{session_alias}/info– information about the group
  • GET /user/{user_id}/groups– user groups
  • GET /user/{user_id}/target_groups– target user groups

Swagger documentation:

After starting the API server, open:http://localhost:8001/docs

🀝 Support and updates

Useful links:

Recommendations for use:

  • Start with test groups
  • Increase the load gradually
  • Check your session status regularly
  • Make database backups

⚠️ DisclaimerΒ : Use this tool responsibly. Follow Telegram’s rules and adhere to the terms of use. The author is not responsible for account suspensions due to improper use.

π‚π€ππ“πˆπŠ ππ„ππˆππ† πˆππƒπŽ
Extract Email dari Text Menggunakan notepad++

Your email address will not be published. Required fields are marked *