Skip to content

TG_Sentinel_bot is a versatile AI-powered Telegram tool that filters messages in channels of any type based on customizable prompts. Detect ads, spam, or any content you define, transferring only safe messages while keeping your channels clean, smart, and fully under your control.

License

Notifications You must be signed in to change notification settings

ExcogitatorWarrior/TG_Sentinel_bot

Repository files navigation

TG_Sentinel_bot

TG_Sentinel_bot is a Telegram moderation tool powered by Python and LLMs.
It can automatically fetch messages from specific channels, analyze them with a local language model, and repost filtered content to your target channel.

The system is designed for flexibility and can be used for tasks like:

  • Ad/Spam filtering
  • Content moderation
  • Automated forwarding/reloading with intelligent scoring

Features

  • 🔗 Channel tracking – fetch messages from one or multiple channels
  • 🤖 LLM-powered processing – analyze message text with a local model (customizable)
  • FastAPI-based microservices – both the database and the LLM backend are exposed via FastAPI servers
  • 🛡 Smart filtering – block ads, spam, or unwanted content using AI-based scoring
  • 📤 Automated reposting – forward or reload messages into a target channel
  • 🗄 SQLite database – keep track of messages and edits
  • ⚙️ Configurable settings – control thresholds, prompt template, and performance

Installation

Requirements

  • Python 3.10+
  • Pyrogram fork with maintence
  • A compiled llama-cpp-python library with CUDA, if you want to run LLM with GPU.
  • Telegram API credentials

Install dependencies:

pip install -r requirements.txt

Getting Telegram API Credentials

To run TG_Sentinel_bot, you need a Telegram API_ID and API_HASH.
Follow these steps:

  1. Go to my.telegram.org and log in with your phone number.
  2. Click API Development Tools.
  3. Create a new app — the name doesn’t matter much.
  4. You’ll receive:
    • API_ID (an integer)
    • API_HASH (a long string of letters/numbers)

Place these values inside your config.py file:

API_ID = 1234567
API_HASH = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

Run and go through following script to make a telegram session:

python Telegram_pyrogram_grasper.py

Open config.py and set your channels:

TRACKED_CHANNELS = ["durov", -1000000000000]
TARGET_CHANNEL = -1000000000000

If you need the ID of a private channel, set its invite link in config.py:

CHANNEL_LINK = "https://t.me/+XXXXXXXXXXXXXX"

Then run:

python Telegram_get_channel_id.py

If you want to run the LLM with GPU using llama-cpp-python, you have two options:

  1. Build your own with CUDA
    Follow the guide: llama-cpp-python CUDA Build

  2. Use prebuilt wheels
    Download the ready-to-use wheel from:
    llama-cpp-output / llama-cuda-wheel-3.16

This wheel is llama-cpp-python version 0.3.16, built with CUDA, compatible with Python 3.13 on Windows.

You can set up the LLM in two ways:

  1. Automatic Download
    Run:
    python DownloadLLM.py
  2. Providing your own weights. You would have to place them locally and attach path within config.py, keep in mind, weights have to be compatible with llama-cpp-python library:
    MODEL_PATH = "models/your_model.gguf"

Running the Bot

After you’ve configured config.py and created your Telegram session make sure that all files in a same folder, then you can start the bot by running:

python TG_Sentinel_lanucher.py

Final Remarks

Thank you for exploring TG_Sentinel_bot, a tool to filter Telegram channels of unwanted content.
Your feedback and discussions are welcome, and I’m always open to new perspectives and collaborations.

If you’re interested in learning more or chatting about my projects, feel free to contact me via Telegram: @ExcogitatorWarrior

About

TG_Sentinel_bot is a versatile AI-powered Telegram tool that filters messages in channels of any type based on customizable prompts. Detect ads, spam, or any content you define, transferring only safe messages while keeping your channels clean, smart, and fully under your control.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages