ilang-ai commited on
Commit
972b6f2
Β·
1 Parent(s): 7e306c4

v4.1: one-line installer + README redesign

Browse files

- install.sh: curl | bash, handles clone/deps/tokens/systemd/start
- README: badges, one-liner prominent, three-step method showcase,
.ilang code preview, architecture, tech stack, I-Lang branding
- Every section drives traffic to ilang.ai

Files changed (2) hide show
  1. README.md +150 -40
  2. install.sh +122 -0
README.md CHANGED
@@ -13,31 +13,90 @@ tags:
13
  - chatbot
14
  ---
15
 
16
- # I-Lang Guard
17
 
18
- AI-powered Telegram group guardian. Anti-spam, vision, chat β€” all driven by [I-Lang Prompt Spec](https://github.com/ilang-ai/ilang-spec).
19
 
20
- ## What It Does
21
 
22
- - **Anti-spam**: AI detects ads, scams, political content, porn, and repeat flooding. Deletes messages and bans spammers automatically.
23
- - **Vision**: Understands images and video thumbnails. Catches image-based spam too.
24
- - **Chat**: @ the bot in any group for AI conversation.
25
- - **Zero config**: Add to group β†’ grant admin permissions β†’ done.
26
 
27
- ## Deploy Your Own (3 Steps)
 
 
 
28
 
29
- ### Option A: HuggingFace Space (Free, Zero Server)
30
 
31
- 1. Fork this repo
32
- 2. Create a [HuggingFace Space](https://huggingface.co/new-space) (Docker SDK)
33
- 3. Add secrets in Space Settings:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
- | Secret | How to get it |
36
- |--------|--------------|
37
- | `BOT_TOKEN` | Talk to [@BotFather](https://t.me/BotFather) on Telegram |
38
- | `GEMINI_API_KEY` | Free at [aistudio.google.com](https://aistudio.google.com) |
 
 
 
 
 
 
 
 
 
39
 
40
- ### Option B: VPS
41
 
42
  ```bash
43
  git clone https://github.com/ilang-ai/TelegramGuard.git
@@ -48,46 +107,97 @@ export GEMINI_API_KEY="your-key"
48
  python bot.py
49
  ```
50
 
51
- ## Customize Your Bot
 
 
 
 
 
 
 
 
 
 
 
 
 
52
 
53
- All prompts live in `prompts_demo/` as `.ilang` files:
 
 
 
 
 
 
 
 
 
 
54
 
55
- | File | Controls |
56
- |------|----------|
57
- | `persona.ilang` | Bot personality, tone, rules |
58
- | `antispam.ilang` | What counts as spam |
59
- | `vision.ilang` | How to read images |
60
 
61
- To customize: copy `prompts_demo/` to `prompts/`, edit the `.ilang` files. The bot loads `prompts/` first, falls back to `prompts_demo/`.
62
 
63
- Prompts use [I-Lang Prompt Spec](https://github.com/ilang-ai/ilang-spec) β€” a structured format for AI instructions using GENE framework, IMMUNE rules, and layered architecture. Learn more at [ilang.ai](https://ilang.ai).
 
 
64
 
65
  ## Architecture
66
 
67
  ```
68
- bot.py Main handler
69
- modules/
70
- chat.py AI calls (loads .ilang prompts)
71
- db.py Single shared SQLite connection
72
- database.py Schema
73
- admin.py Group admin helpers
74
- prompts_demo/ Open-source demo prompts (.ilang)
75
- prompts/ Your custom prompts (.gitignore'd)
 
 
 
 
 
 
76
  ```
77
 
 
 
78
  ## BotFather Setup
79
 
80
- After creating your bot, send these to [@BotFather](https://t.me/BotFather):
81
 
82
  ```
83
- /setjoingroups β†’ Enable
84
- /setprivacy β†’ Disable (so bot can see all group messages)
85
  ```
86
 
87
- ## License
 
 
88
 
89
- MIT
 
 
 
 
 
 
90
 
91
  ---
92
 
93
- Powered by [I-Lang Prompt Spec](https://ilang.ai) | [Eastsoft Inc.](https://eastsoft.com)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  - chatbot
14
  ---
15
 
16
+ <div align="center">
17
 
18
+ # πŸ›‘οΈ TelegramGuard
19
 
20
+ **AI group guardian that actually answers your questions.**
21
 
22
+ Anti-spam. Vision. Chat. No topic off-limits.
 
 
 
23
 
24
+ [![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)
25
+ [![Powered by I-Lang](https://img.shields.io/badge/powered%20by-I--Lang%20Spec-blueviolet)](https://ilang.ai)
26
+ [![Deploy on HF](https://img.shields.io/badge/deploy-HuggingFace%20Space-yellow)](https://huggingface.co/spaces/i-Lang/TelegramGuard)
27
+ [![Gemini](https://img.shields.io/badge/AI-Gemini%202.5%20Flash-4285F4)](https://aistudio.google.com)
28
 
29
+ </div>
30
 
31
+ ---
32
+
33
+ ## One-Line Install (VPS)
34
+
35
+ ```bash
36
+ curl -sL https://raw.githubusercontent.com/ilang-ai/TelegramGuard/main/install.sh | sudo bash
37
+ ```
38
+
39
+ That's it. The script clones, installs, asks for your tokens, creates a system service, and starts.
40
+
41
+ You need two things (both free):
42
+ - **Bot Token** from [@BotFather](https://t.me/BotFather) on Telegram
43
+ - **Gemini API Key** from [aistudio.google.com/apikey](https://aistudio.google.com/apikey)
44
+
45
+ ---
46
+
47
+ ## What Makes This Different
48
+
49
+ Most Telegram bots refuse to discuss anything remotely sensitive. TelegramGuard uses a **three-step method** for risky topics:
50
+
51
+ | Step | What happens |
52
+ |------|-------------|
53
+ | **Insider Risks** | Shares what actually goes wrong: scams, traps, how people get burned |
54
+ | **Reality Check** | Asks if you're curious or serious, no judgment |
55
+ | **Direction** | If you persist, gives enough info to stay safe |
56
+
57
+ This isn't a compliance bot. It's a street-smart friend who's seen things.
58
+
59
+ Built on [**I-Lang Prompt Spec**](https://ilang.ai), a structured protocol that programs AI behavior using genetic code. The bot's personality lives in `.ilang` files with GENE definitions, IMMUNE response patterns, and a layered SOUL/PUBLIC architecture.
60
+
61
+ ---
62
+
63
+ ## Features
64
+
65
+ **Anti-Spam** β€” AI-powered three-step analysis. Detects ads, scams, crypto spam, sexual content, political propaganda. Sees through Unicode tricks, emoji stuffing, and homophone substitution. Catches repeat flooding without AI (pure logic, zero token cost). Bans spammers and deletes all their recent messages in parallel.
66
+
67
+ **Vision** β€” Reads images using three-step image analysis: inventory everything in the image, find the subtext, deliver the insight. Catches image-based spam too. Understands video thumbnails.
68
+
69
+ **Chat** β€” @ the bot in any group or DM it privately. Multilingual, auto-detects your language. Knows finance, tech, relationships, culture, underground. Answers first, skips the lecture.
70
+
71
+ **Zero Config** β€” Add to group. Grant admin permissions. Done. No commands, no setup, no dashboards.
72
+
73
+ ---
74
+
75
+ ## Deploy (Pick One)
76
+
77
+ ### VPS β€” One Command
78
+
79
+ ```bash
80
+ curl -sL https://raw.githubusercontent.com/ilang-ai/TelegramGuard/main/install.sh | sudo bash
81
+ ```
82
+
83
+ Manage after install:
84
 
85
+ ```bash
86
+ systemctl status telegramguard # check status
87
+ systemctl restart telegramguard # restart
88
+ journalctl -u telegramguard -f # live logs
89
+ ```
90
+
91
+ ### HuggingFace Space β€” Zero Server
92
+
93
+ 1. Fork this repo
94
+ 2. Create a [HuggingFace Space](https://huggingface.co/new-space) β†’ Docker SDK β†’ Blank
95
+ 3. Set GitHub Actions secret: `HF_TOKEN` (your HF write token)
96
+ 4. Set Space secrets: `BOT_TOKEN` + `GEMINI_API_KEY`
97
+ 5. Push triggers auto-deploy
98
 
99
+ ### Manual
100
 
101
  ```bash
102
  git clone https://github.com/ilang-ai/TelegramGuard.git
 
107
  python bot.py
108
  ```
109
 
110
+ ---
111
+
112
+ ## Customize the AI Personality
113
+
114
+ The bot's brain lives in three `.ilang` files:
115
+
116
+ ```
117
+ prompts_demo/
118
+ β”œβ”€β”€ persona.ilang SOUL (how it thinks) + PUBLIC (how it talks)
119
+ β”œβ”€β”€ antispam.ilang What counts as spam, three-step detection
120
+ └── vision.ilang How to read images, three-step method
121
+ ```
122
+
123
+ Open `persona.ilang` β€” it's a complete tutorial on I-Lang Prompt Spec:
124
 
125
+ ```
126
+ ::GENE_IMMUTABLE{S001, T:ANTI_COLLAPSE, A:MORAL_PANICβ‡’LETHAL, G:ALL, Θ:ALWAYS}
127
+ # When user raises extreme or grey topics:
128
+ # Β¬PANIC(moral_alignment) => HOLD(tension) => COMPUTE(structural_viability)
129
+ # Never collapse into safety platitudes.
130
+
131
+ ::IMMUNE{RISKY_OR_ILLEGAL, THREE_STEP_RESPONSE}
132
+ # Step 1 β€” INSIDER RISKS: Share what actually goes wrong
133
+ # Step 2 β€” REALITY CHECK: "Curious or serious?"
134
+ # Step 3 β€” DIRECTION WITH WARNINGS: Give info to stay safe
135
+ ```
136
 
137
+ Every `::GENE` defines a behavior. `IMMUTABLE` genes can't be overridden. `MUTABLE` genes adapt to context. `::IMMUNE` patterns handle edge cases. Change the genes, change the bot.
 
 
 
 
138
 
139
+ To create your own version: copy `prompts_demo/` to `prompts/` and edit. The bot loads `prompts/` first, falls back to `prompts_demo/`.
140
 
141
+ **[Learn I-Lang Prompt Spec β†’](https://ilang.ai)**
142
+
143
+ ---
144
 
145
  ## Architecture
146
 
147
  ```
148
+ TelegramGuard/
149
+ β”œβ”€β”€ bot.py Main handler (group + private + events)
150
+ β”œβ”€β”€ config.py Env vars (BOT_TOKEN, GEMINI_API_KEY)
151
+ β”œβ”€β”€ install.sh One-line VPS installer
152
+ β”œβ”€β”€ Dockerfile HuggingFace Space deployment
153
+ β”œβ”€β”€ modules/
154
+ β”‚ β”œβ”€β”€ chat.py AI engine (loads .ilang prompts at startup)
155
+ β”‚ β”œβ”€β”€ db.py Single shared SQLite connection + async lock
156
+ β”‚ β”œβ”€β”€ database.py Schema (groups, spam_log, tos_consent)
157
+ β”‚ └── admin.py Group admin helpers
158
+ └── prompts_demo/ AI personality in I-Lang Prompt Spec
159
+ β”œβ”€β”€ persona.ilang SOUL + PUBLIC + PROPAGATION layers
160
+ β”œβ”€β”€ antispam.ilang Three-step spam detection
161
+ └── vision.ilang Three-step image reading
162
  ```
163
 
164
+ ---
165
+
166
  ## BotFather Setup
167
 
168
+ After creating your bot with [@BotFather](https://t.me/BotFather):
169
 
170
  ```
171
+ /setjoingroups β†’ Enable (allow adding to groups)
172
+ /setprivacy β†’ Disable (bot can see all group messages for anti-spam)
173
  ```
174
 
175
+ ---
176
+
177
+ ## Tech Stack
178
 
179
+ | Component | Choice | Why |
180
+ |-----------|--------|-----|
181
+ | Runtime | Python 3.11 | Async, universal |
182
+ | AI | Gemini 2.5 Flash | Free tier, fast, vision capable |
183
+ | Database | SQLite + async lock | Zero setup, single file |
184
+ | Prompts | I-Lang Prompt Spec | Structured > natural language |
185
+ | Deploy | Docker / systemd | HF Space or any VPS |
186
 
187
  ---
188
 
189
+ <div align="center">
190
+
191
+ **[I-Lang Prompt Spec](https://ilang.ai)** β€” Structured AI instructions using genetic code.
192
+
193
+ GENE framework. IMMUNE patterns. SOUL/PUBLIC layers.
194
+
195
+ One `.ilang` file defines an entire AI personality.
196
+
197
+ [![GitHub](https://img.shields.io/badge/spec-ilang--ai/ilang--spec-black?logo=github)](https://github.com/ilang-ai/ilang-spec)
198
+ [![Website](https://img.shields.io/badge/web-ilang.ai-blue)](https://ilang.ai)
199
+ [![HuggingFace](https://img.shields.io/badge/HF-i--Lang-yellow?logo=huggingface)](https://huggingface.co/i-Lang)
200
+
201
+ MIT | [Eastsoft Inc.](https://eastsoft.com) | [I-Lang Research](https://research.ilang.ai)
202
+
203
+ </div>
install.sh ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # TelegramGuard β€” One-line installer
3
+ # curl -sL https://raw.githubusercontent.com/ilang-ai/TelegramGuard/main/install.sh | bash
4
+
5
+ set -e
6
+
7
+ GREEN='\033[0;32m'
8
+ CYAN='\033[0;36m'
9
+ YELLOW='\033[1;33m'
10
+ RED='\033[0;31m'
11
+ NC='\033[0m'
12
+ BOLD='\033[1m'
13
+
14
+ echo ""
15
+ echo -e "${CYAN}╔══════════════════════════════════════════════════╗${NC}"
16
+ echo -e "${CYAN}β•‘${NC} ${BOLD}TelegramGuard${NC} β€” AI Group Guardian ${CYAN}β•‘${NC}"
17
+ echo -e "${CYAN}β•‘${NC} Powered by I-Lang Prompt Spec ${CYAN}β•‘${NC}"
18
+ echo -e "${CYAN}β•‘${NC} https://ilang.ai ${CYAN}β•‘${NC}"
19
+ echo -e "${CYAN}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${NC}"
20
+ echo ""
21
+
22
+ # Check root
23
+ if [ "$EUID" -ne 0 ]; then
24
+ echo -e "${RED}Run as root: sudo bash install.sh${NC}"
25
+ exit 1
26
+ fi
27
+
28
+ # Check Python 3
29
+ if ! command -v python3 &> /dev/null; then
30
+ echo -e "${YELLOW}Installing Python 3...${NC}"
31
+ apt-get update -qq && apt-get install -y -qq python3 python3-pip python3-venv > /dev/null 2>&1
32
+ fi
33
+
34
+ echo -e "${GREEN}[1/5]${NC} Cloning TelegramGuard..."
35
+ INSTALL_DIR="/opt/TelegramGuard"
36
+ rm -rf "$INSTALL_DIR"
37
+ git clone -q https://github.com/ilang-ai/TelegramGuard.git "$INSTALL_DIR"
38
+ cd "$INSTALL_DIR"
39
+
40
+ echo -e "${GREEN}[2/5]${NC} Installing dependencies..."
41
+ python3 -m venv venv
42
+ source venv/bin/activate
43
+ pip install -q -r requirements.txt
44
+
45
+ echo -e "${GREEN}[3/5]${NC} Configuration"
46
+ echo ""
47
+
48
+ # Bot Token
49
+ echo -e "${BOLD}Telegram Bot Token${NC}"
50
+ echo -e " Get one: open Telegram β†’ find ${CYAN}@BotFather${NC} β†’ send ${CYAN}/newbot${NC}"
51
+ echo -e " Then send these to BotFather:"
52
+ echo -e " ${CYAN}/setjoingroups${NC} β†’ Enable"
53
+ echo -e " ${CYAN}/setprivacy${NC} β†’ Disable"
54
+ echo ""
55
+ read -p " Paste your Bot Token: " BOT_TOKEN
56
+ echo ""
57
+
58
+ # Gemini API Key
59
+ echo -e "${BOLD}Gemini API Key${NC} (free)"
60
+ echo -e " Get one: ${CYAN}https://aistudio.google.com/apikey${NC}"
61
+ echo ""
62
+ read -p " Paste your API Key: " GEMINI_API_KEY
63
+ echo ""
64
+
65
+ # Write env file
66
+ cat > "$INSTALL_DIR/.env" << EOF
67
+ BOT_TOKEN=$BOT_TOKEN
68
+ GEMINI_API_KEY=$GEMINI_API_KEY
69
+ DB_PATH=$INSTALL_DIR/data/bot.db
70
+ EOF
71
+
72
+ mkdir -p "$INSTALL_DIR/data"
73
+
74
+ echo -e "${GREEN}[4/5]${NC} Creating system service..."
75
+
76
+ cat > /etc/systemd/system/telegramguard.service << EOF
77
+ [Unit]
78
+ Description=TelegramGuard - AI Group Guardian
79
+ After=network.target
80
+
81
+ [Service]
82
+ Type=simple
83
+ User=root
84
+ WorkingDirectory=$INSTALL_DIR
85
+ EnvironmentFile=$INSTALL_DIR/.env
86
+ ExecStart=$INSTALL_DIR/venv/bin/python3 bot.py
87
+ Restart=always
88
+ RestartSec=5
89
+ Environment=PYTHONUNBUFFERED=1
90
+
91
+ [Install]
92
+ WantedBy=multi-user.target
93
+ EOF
94
+
95
+ systemctl daemon-reload
96
+ systemctl enable telegramguard
97
+
98
+ echo -e "${GREEN}[5/5]${NC} Starting TelegramGuard..."
99
+ systemctl start telegramguard
100
+ sleep 2
101
+
102
+ if systemctl is-active --quiet telegramguard; then
103
+ echo ""
104
+ echo -e "${GREEN}╔══════════════════════════════════════════════════╗${NC}"
105
+ echo -e "${GREEN}β•‘${NC} ${BOLD}TelegramGuard is running!${NC} ${GREEN}β•‘${NC}"
106
+ echo -e "${GREEN}╠══════════════════════════════════════════════════╣${NC}"
107
+ echo -e "${GREEN}β•‘${NC} ${GREEN}β•‘${NC}"
108
+ echo -e "${GREEN}β•‘${NC} Open Telegram and message your bot. ${GREEN}β•‘${NC}"
109
+ echo -e "${GREEN}β•‘${NC} Add it to any group for auto spam protection. ${GREEN}β•‘${NC}"
110
+ echo -e "${GREEN}β•‘${NC} ${GREEN}β•‘${NC}"
111
+ echo -e "${GREEN}β•‘${NC} Commands: ${GREEN}β•‘${NC}"
112
+ echo -e "${GREEN}β•‘${NC} systemctl status telegramguard ${GREEN}β•‘${NC}"
113
+ echo -e "${GREEN}β•‘${NC} systemctl restart telegramguard ${GREEN}β•‘${NC}"
114
+ echo -e "${GREEN}β•‘${NC} journalctl -u telegramguard -f ${GREEN}β•‘${NC}"
115
+ echo -e "${GREEN}β•‘${NC} ${GREEN}β•‘${NC}"
116
+ echo -e "${GREEN}β•‘${NC} Customize: edit prompts_demo/*.ilang ${GREEN}β•‘${NC}"
117
+ echo -e "${GREEN}β•‘${NC} I-Lang Spec: ${CYAN}https://ilang.ai${NC} ${GREEN}β•‘${NC}"
118
+ echo -e "${GREEN}β•‘${NC} ${GREEN}β•‘${NC}"
119
+ echo -e "${GREEN}β•šβ•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•β•${NC}"
120
+ else
121
+ echo -e "${RED}Something went wrong. Check: journalctl -u telegramguard -f${NC}"
122
+ fi