Skip to content

newfpv/ChannelModerationBot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🛡️ Telegram Channel Moderation Bot

Python Docker Telebot

Automatic guardian for your Telegram channels: removes forbidden words, media and stickers.

Channel Moderation Bot is a reliable and lightweight bot moderator for Telegram channel administrators. It runs in the background, scans every post (including photo and video captions), and automatically takes action when stop words are detected. It is ideal for cleaning news and meme channels from spam, advertisements and unwanted content.


✨ Bot Features

  • Dual control: The bot independently monitors two different channels (for example, a channel with memes and a Channel with news), using its own individual database of forbidden words for each.
  • Media Analysis: Not only the regular text is checked, but also the `caption' (descriptions) for photos, circles, videos and animations.
  • Strict file moderation: Any Sticker and Document (files) sent to the channel are deleted automatically and permanently.
  • Archive of violators: If the message contains a forbidden word, the bot first forwards it to a private archive channel (for logs), and then instantly deletes it from public access (up to 3 deletion attempts are guaranteed).
  • Security: Only the administrator whose ID is specified in the configuration has access to the management commands.

⚙️ How it works

It is based on the pyTelegramBotAPI' library. The bot uses the channel_post_handlermechanism to instantly intercept new posts. Thanks to the.envfile all sensitive data is securely protected, and the use of a lightweight filedata.txt ` allows you to store a list of words without having to deploy complex databases (SQL/PostgreSQL).

🚀 Installation and launch (Docker)

The project is fully ready for deployment via Docker Compose. This is the cleanest and most reliable method.

Step 1. Cloning and configuration

git clone [https://github.com/your-repo/telegram-moderation-bot.git](https://github.com/your-repo/telegram-moderation-bot.git)
cd telegram-moderation-bot

Create a .env file based on the example: ``bash cp .env.example .env nano .env


Enter your details inside:
* `BOT_TOKEN' — the token received from @BotFather.
* `ADMIN_USER_ID' is your Telegram ID (you can find out via @getmyid_bot).
* `CHANNEL_MEMES_ID`, `CHANNEL_NEWS_ID` — ID of channels to moderate (start with `-100`).
* `CHANNEL_ARCHIVE_ID' is the ID of the archive channel for forwarding violations.

*Important: The bot must be appointed an Administrator in all three channels with the right to delete and publish messages.*

### Step 2. Build and launch

Launch the container with one command:
``bash
docker-compose up -d --build

The bot will automatically download the Python 3.11 image, install the dependencies, and run in the background. You can check the logs with the command: bash docker logs banword -f

Management (Admin Panel)

You don't need to go into the code or the server to update the database of words. Just send a command to the bot in private messages.:

  • `/start' — To open the help menu.
  • /add1 [word] / /add2 [word] — Add the word to the spam filter of the first or second channel.
  • /del1 [word] / /del2 [word] — Remove the word from the filter.
  • /list1 / `/list2' — Displays the current list of prohibited words.

All changes are applied instantly and immediately saved to the hard drive.

🗄 Database structure

The list of words is stored locally in a file data.txt in the format: text -1001758987408||advertising;spam;casino -1001960935944||subscribe;shock;tin The file is read at startup and overwritten with any command to add/remove from Telegram.

📄 License

This project is distributed under the GNU GPLv3 license.

☕ Support

About

Lightweight Telegram bot for dual-channel moderation: filters banned words, media captions, and stickers

Topics

Resources

License

Stars

Watchers

Forks

Contributors