text stringclasses 4
values |
|---|
python-telegram-bot[job-queue]>=21.0 |
openai>=1.40 |
Pillow>=10.0 |
aiosqlite>=0.20.0 |
π‘οΈ antispam.bot
The AI guardian that keeps your Telegram groups clean β and actually answers your questions.
Open source (MIT), zero config, self-hostable β the TelegramGuard project.
π English Β· δΈζ Β· Π ΡΡΡΠΊΠΈΠΉ Β· EspaΓ±ol Β· Ψ§ΩΨΉΨ±Ψ¨ΩΨ© Β· ΩΨ§Ψ±Ψ³Ϋ
Add it to your group (zero setup)
Add the official bot β no install, no config, no cost.
β @iLangGuardBot
- Search
@iLangGuardBoton Telegram - Add it to your group
- Give it admin β delete messages + ban users
- Done. Spam is cleaned automatically; @ it anytime with a question.
You can also DM it directly for AI chat.
What it does
π« Anti-Spam β Catches ads, scams, crypto & gambling spam. Sees through Unicode lookalikes, full-width and zero-width tricks, emoji stuffing and slang. A zero-cost pre-filter kills the obvious stuff before it ever reaches the AI, and repeat-flooding is caught with no AI call at all.
ποΈ Vision β Reads images and video thumbnails to catch image-based ads and QR-code scams. In chat, it reads the story behind a photo, not just the pixels.
π¬ Chat β @ it in any group or DM it privately. Multilingual, auto-detects your language. Ask it anything and get a clear, useful answer β factual on sensitive topics, with sensible boundaries on genuinely harmful ones.
Self-Host
Bring any OpenAI-compatible AI provider β SiliconFlow (default), OpenAI, DeepSeek, or a local model. You need two things:
- Bot Token β @BotFather β
/newbot - AI API Key β from your provider (default targets SiliconFlow)
Option 1 β VPS (one command)
curl -sL https://raw.githubusercontent.com/ilang-ai/TelegramGuard/main/install.sh | sudo bash
Clones, installs dependencies, prompts for your two keys, and runs as a systemd service. Manage it with:
systemctl status telegramguard # status
systemctl restart telegramguard # restart
journalctl -u telegramguard -f # live logs
Option 2 β HuggingFace Space (free, no server)
- Fork this repo
- Create a HuggingFace Space β Docker SDK β Blank
- GitHub repo β Settings β Secrets β add
HF_TOKEN(your HF write token) - HF Space β Settings β Secrets β add
BOT_TOKEN+AI_API_KEY - HF Space β Settings β enable persistent storage so
/data(the SQLite DB) is writable β or add aDB_PATHsecret pointing somewhere writable - Push to GitHub β it auto-deploys to the Space
Option 3 β Manual
git clone https://github.com/ilang-ai/TelegramGuard.git
cd TelegramGuard
pip install -r requirements.txt
cp .env.example .env # fill in BOT_TOKEN + AI_API_KEY
set -a; source .env; set +a # load .env into the environment
python bot.py
After creating your bot, send to @BotFather: /setjoingroups β Enable and /setprivacy β Disable (so it can see group messages).
Configuration
Everything is set via environment variables β see .env.example:
| Variable | Default | Purpose |
|---|---|---|
BOT_TOKEN |
(required) | Telegram bot token |
AI_API_KEY |
(required) | OpenAI-compatible API key |
AI_BASE_URL |
https://api.siliconflow.cn/v1 |
Provider endpoint |
AI_MODEL |
deepseek-ai/DeepSeek-V4-Flash |
Text model |
AI_VISION_MODELS |
Qwen/Qwen3-VL-30B⦠|
Vision fallback chain (comma-separated) |
AI_AUDIO_MODEL |
Qwen/Qwen3-Omni-30B-A3B-Instruct |
Voice-message model |
AI_IMAGE_MAX_WIDTH |
600 |
Downscale width before vision calls |
LEXICON_HARD_THRESHOLD |
6 |
Slang pre-filter strictness (higher = stricter) |
Customize the AI
The bot's brain lives in plain .ilang files β I-Lang Prompt Spec, where each ::GENE defines a behavior.
prompts_demo/
βββ persona.ilang how it thinks + how it talks
βββ antispam.ilang what counts as spam
βββ vision.ilang how it reads images
::GENE_IMMUTABLE{S002, T:RUTHLESS_RED_TEAM, A:FLATTERβFAIL, G:ALL, Ξ:ALWAYS}
# Show it a plan and it hunts the fatal flaw instead of praising.
::GENE_MUTABLE{P002, T:CONCISE, G:ALL, Ξ:ALWAYS}
# 2-3 sentences. Answer first, detail after, zero filler.
::IMMUNE{SPAM, DETECT_THEN_NUKE}
# Ads / scams / flooding β delete + strike, see through evasion.
Change the genes, change the bot. To customize: copy prompts_demo/ to prompts/ (loaded first) and edit.
Architecture
TelegramGuard/
βββ bot.py Entry β handlers (group Β· private Β· events)
βββ config.py Env config
βββ install.sh One-command VPS installer
βββ Dockerfile Container build
βββ modules/
β βββ ai_provider.py OpenAI-compatible AI layer (text Β· vision Β· audio)
β βββ chat.py Prompt orchestration (loads .ilang)
β βββ prefilter.py Zero-cost spam pre-filter + triage
β βββ lexicon.py Slang / evasion normalization + scoring
β βββ ilang_judge.py I-Lang decision function
β βββ admin.py Group admin
β βββ db.py Shared SQLite + async lock
β βββ database.py Schema
βββ prompts_demo/ AI personality (.ilang files)
Built with I-Lang Prompt Spec β structured AI instructions as genetic code.
MIT Β· Β© iLang Inc. Β· antispam.bot Β· ilang.ai
- Downloads last month
- 179