Designed for better message forwarding in Telegram.
Use the "topic" feature to achieve a better PM bot.
Forward users' messages to topics in the group. Each user corresponds to a topic.
- Privacy: Admins' accounts are not exposed.
- Flexibility: Each user corresponds to an independent topic, and the experience is almost the same as private chat.
- Teamwork: Multiple admins can handle users' messages.
- Multi-language: Supports multiple languages, including English, Chinese and Japanese.
- Auto Response: Automatically replies to users' messages with predefined messages, and supports detection with regex. Allows setting active time for auto-reply.
- Captcha: Added a human verification feature to ensure that users are real people, effectively preventing the sending
of spam messages. Supports multiple verification methods:
- Button Verification: Simple button click verification
- Math Verification: Users solve simple math problems to prove they are human
- TGuard Verification: Advanced human verification service integrated with TGuard, supporting multiple captcha drivers (hCaptcha, Cap.js, Turnstile) with a beautiful Telegram Mini Web App interface
- Spam Protection: Intelligent spam filtering system with keyword-based detection. Supports extensible detector interface for integrating AI models, external APIs, and custom detection methods.
- Broadcast Message: Allows admins to send a message to all users at once.
- Create a bot from @BotFather and get the token.
- Create a group with topics, and add the bot as an admin.
- Get the group ID.
This step can be done by inviting @sc_ui_bot to the group and use the command
/id. - Deploy BetterForward to a server.
Any messages sent to the bot will be forwarded to the corresponding topic in the group.
More options and settings can be found by sending the /help command to the bot in the group.
The following are the available language options:
- English -
en_US - Chinese -
zh_CN - Japanese -
ja_JP
We welcome contributions to add more languages.
- Download the
docker-compose.ymlfile:
wget https://github.com/SideCloudGroup/BetterForward/raw/refs/heads/main/docker-compose.yml-
Edit the
docker-compose.ymlfile and replace the placeholder values:your_bot_token_herewith your actual bot tokenyour_group_id_herewith your actual group IDzh_CNwith your preferred language (en_US,zh_CN, orja_JP)- Leave
TG_APIempty or set your custom API endpoint WORKER=2sets the number of worker threads (default: 2)
-
Run with Docker Compose:
docker compose up -dReplace /path/to/data with your actual data directory path:
docker run -d --name betterforward \
-e TOKEN=<your_bot_token> \
-e GROUP_ID=<your_group_id> \
-e LANGUAGE=<language> \
-e WORKER=2 \
-v /path/to/data:/app/data \
--restart unless-stopped \
ghcr.io/sidecloudgroup/betterforward:latestIf you need to use a custom API, you can set the environment variable TG_API. Leave it empty or unset to use the
default API.
BetterForward supports multithreading through the WORKER parameter to improve performance and handle concurrent
requests:
- Default:
WORKER=2- Balanced performance for most deployments - High Traffic:
WORKER=3-5- Recommended for high-traffic scenarios - Thread Safety: The application uses thread-safe database operations and message queues to prevent conflicts
- Conflict Resolution: Database transactions and locking mechanisms ensure data consistency across multiple worker threads
If you deploy this project using Docker, you can use WatchTower to quickly update. Please adjust the container name yourself. Use the following command to update:
docker run --rm \
-v /var/run/docker.sock:/var/run/docker.sock \
containrrr/watchtower -cR \
<Container Name>BetterForward supports multiple human verification methods to ensure only real users can send messages.
- Button Verification - The simplest verification method, users only need to click a button
- Math Verification - Users need to solve simple math problems to prove they are human
- TGuard Verification - Advanced human verification service integrated with TGuard
- Supports multiple captcha drivers: hCaptcha, Cap.js, Turnstile
- Beautiful verification interface via Telegram Mini Web App
- Requires TGuard API URL and API key configuration
- Automatically marks users as verified after completion
- Send
/helpcommand in the main group topic - Select "🌐 TGuard API Settings" menu
- Set TGuard API URL (e.g.,
https://your-tguard-domain.com) - Set TGuard API key
- Return to captcha settings and select "TGuard Captcha"
- When a user sends their first message, BetterForward creates a verification request via TGuard API
- TGuard returns a verification URL and token
- BetterForward sends a message with a verification button (Mini Web App) to the user
- User clicks the button and completes human verification in the Web App
- After verification, when the user sends another message, BetterForward checks the verification status
- Once verified, user messages are forwarded normally
BetterForward includes an intelligent spam filtering system to help you effectively manage and isolate spam content.
- Smart Matching: Supports fuzzy matching to automatically identify messages containing spam keywords
- High Performance: Uses optimized regex with O(n) time complexity for extremely fast processing
- Easy Management: Add, view, and delete keywords through the admin menu
- Auto Isolation: Matched spam messages are automatically forwarded to a dedicated spam topic without creating user threads
- Silent Mode: Forwarding uses silent mode to avoid notification spam
- Send
/helpcommand in the main group topic - Select "🚫 Spam Keywords" menu
- Click "➕ Add Keyword" to add keywords to filter
- Click "📋 View Keywords" to manage existing keywords
Keyword configuration is saved in data/spam_keywords.json and supports manual editing.
/terminate [User ID]: Ends the conversation with a specified user. When this command is issued within a conversation thread, there is no need to include the User ID; the current conversation will be terminated automatically. The user will not receive any further prompts or notifications./help: Displays the help menu, which includes a list of available commands and their instructions./ban: Prevents the user from sending more messages. This command is only applicable within the specific conversation thread where it is executed./unban [User ID]: Reinstates the ability for a user to send messages. If no User ID is specified, the command will apply to the user in the current conversation thread.
- Telegram Channel @betterforward
Please use issues for bug reports and feature requests.