ilang-ai commited on
Commit ·
ecdeed3
1
Parent(s): 7c1cf27
v3.0: international edition — universal prompts, English UI, multilingual bot
Browse files- Persona: universal personality, auto-detect language, boundary handler (split don't refuse)
- Antispam: language-agnostic three-step analysis
- Vision: universal three-step image reading
- All UI strings: English (bot auto-detects user language for replies)
- GENE/IMMUNE framework showcased in every .ilang file
- Safety filters: BLOCK_NONE for all Gemini categories
- bot.py +44 -44
- modules/chat.py +14 -14
- prompts_demo/antispam.ilang +44 -45
- prompts_demo/persona.ilang +88 -113
- prompts_demo/vision.ilang +24 -22
bot.py
CHANGED
|
@@ -31,15 +31,15 @@ logging.basicConfig(
|
|
| 31 |
logger = logging.getLogger(__name__)
|
| 32 |
|
| 33 |
TOS_TEXT = (
|
| 34 |
-
"I-Lang Guard
|
| 35 |
-
"
|
| 36 |
-
"-
|
| 37 |
-
"-
|
| 38 |
-
"
|
| 39 |
-
"- Bot
|
| 40 |
-
"-
|
| 41 |
-
"-
|
| 42 |
-
"
|
| 43 |
)
|
| 44 |
|
| 45 |
|
|
@@ -69,7 +69,7 @@ def _ctx_info(context):
|
|
| 69 |
parts = []
|
| 70 |
history = context.user_data.get("history", [])
|
| 71 |
if not history:
|
| 72 |
-
parts.append("NEW_SESSION:
|
| 73 |
return " | ".join(parts)
|
| 74 |
|
| 75 |
|
|
@@ -91,7 +91,7 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 91 |
intent, device, reply = await ai_text(
|
| 92 |
"/start",
|
| 93 |
history=None,
|
| 94 |
-
context_info="NEW_SESSION:
|
| 95 |
)
|
| 96 |
await update.message.reply_text(reply)
|
| 97 |
context.user_data.setdefault("history", []).append({"role": "assistant", "text": reply})
|
|
@@ -100,8 +100,8 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 100 |
await register_group(chat_id, update.effective_chat.title)
|
| 101 |
if not await check_tos(chat_id):
|
| 102 |
keyboard = InlineKeyboardMarkup([
|
| 103 |
-
[InlineKeyboardButton("
|
| 104 |
-
[InlineKeyboardButton("
|
| 105 |
])
|
| 106 |
await update.message.reply_text(TOS_TEXT, reply_markup=keyboard)
|
| 107 |
else:
|
|
@@ -111,13 +111,13 @@ async def cmd_start(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
| 111 |
async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 112 |
if update.effective_chat.type == "private":
|
| 113 |
await update.message.reply_text(
|
| 114 |
-
"
|
| 115 |
-
"
|
| 116 |
-
"
|
| 117 |
)
|
| 118 |
else:
|
| 119 |
await update.message.reply_text(
|
| 120 |
-
"
|
| 121 |
)
|
| 122 |
|
| 123 |
|
|
@@ -157,7 +157,7 @@ async def handle_group_message(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 157 |
if (text or has_media) and (is_mention or is_reply_to_bot):
|
| 158 |
clean = text.replace("@" + context.bot.username, "").strip() if (text and is_mention) else (text.strip() if text else "")
|
| 159 |
if not tos_ok:
|
| 160 |
-
reply = "
|
| 161 |
else:
|
| 162 |
g_history = context.chat_data.setdefault("group_history", [])
|
| 163 |
if msg.photo:
|
|
@@ -166,7 +166,7 @@ async def handle_group_message(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 166 |
img_data = bytes(await f.download_as_bytearray())
|
| 167 |
reply = await ai_group_vision(img_data, caption=clean, history=g_history)
|
| 168 |
except Exception:
|
| 169 |
-
reply = "
|
| 170 |
elif msg.video:
|
| 171 |
if msg.video.thumbnail:
|
| 172 |
try:
|
|
@@ -175,15 +175,15 @@ async def handle_group_message(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 175 |
reply = await ai_group_vision(vimg, caption=clean, history=g_history)
|
| 176 |
except Exception:
|
| 177 |
if clean:
|
| 178 |
-
g_history.append({"role": "user", "text": "[
|
| 179 |
-
reply = await ai_group_reply("[
|
| 180 |
else:
|
| 181 |
-
reply = "
|
| 182 |
elif clean:
|
| 183 |
-
g_history.append({"role": "user", "text": "[
|
| 184 |
-
reply = await ai_group_reply("[
|
| 185 |
else:
|
| 186 |
-
reply = "
|
| 187 |
else:
|
| 188 |
g_history.append({"role": "user", "text": clean})
|
| 189 |
reply = await ai_group_reply(clean, g_history)
|
|
@@ -279,8 +279,8 @@ async def handle_group_message(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 279 |
context.bot_data["perm_remind_" + str(chat_id)] = _time.time()
|
| 280 |
try:
|
| 281 |
await msg.reply_text(
|
| 282 |
-
"\u26a0\ufe0f
|
| 283 |
-
"
|
| 284 |
)
|
| 285 |
except Exception:
|
| 286 |
pass
|
|
@@ -312,7 +312,7 @@ async def handle_private_photo(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 312 |
file = await context.bot.get_file(msg.photo[-1].file_id)
|
| 313 |
img_bytes = bytes(await file.download_as_bytearray())
|
| 314 |
except Exception:
|
| 315 |
-
await msg.reply_text("
|
| 316 |
return
|
| 317 |
intent, device, reply = await ai_vision(img_bytes, caption, history, _ctx_info(context))
|
| 318 |
await _handle_ai_result(intent, device, reply, msg, user_id, context)
|
|
@@ -330,7 +330,7 @@ async def handle_private_voice(update: Update, context: ContextTypes.DEFAULT_TYP
|
|
| 330 |
audio_bytes = bytes(await file.download_as_bytearray())
|
| 331 |
mime = msg.voice.mime_type or "audio/ogg"
|
| 332 |
except Exception:
|
| 333 |
-
await msg.reply_text("
|
| 334 |
return
|
| 335 |
intent, device, reply = await ai_voice(audio_bytes, mime, history, _ctx_info(context))
|
| 336 |
await _handle_ai_result(intent, device, reply, msg, user_id, context)
|
|
@@ -350,8 +350,8 @@ async def handle_my_chat_member(update: Update, context: ContextTypes.DEFAULT_TY
|
|
| 350 |
await delete_tos(chat_id)
|
| 351 |
await register_group(chat_id, result.chat.title)
|
| 352 |
keyboard = InlineKeyboardMarkup([
|
| 353 |
-
[InlineKeyboardButton("
|
| 354 |
-
[InlineKeyboardButton("
|
| 355 |
])
|
| 356 |
await context.bot.send_message(chat_id, TOS_TEXT, reply_markup=keyboard)
|
| 357 |
elif old in ("member", "administrator") and new in ("left", "kicked"):
|
|
@@ -375,14 +375,14 @@ async def handle_tos_callback(update: Update, context: ContextTypes.DEFAULT_TYPE
|
|
| 375 |
admins = await context.bot.get_chat_administrators(chat_id)
|
| 376 |
admin_ids = [a.user.id for a in admins]
|
| 377 |
if user_id not in admin_ids:
|
| 378 |
-
await query.answer("
|
| 379 |
return
|
| 380 |
except Exception:
|
| 381 |
pass
|
| 382 |
|
| 383 |
if is_accept:
|
| 384 |
await record_tos(chat_id, user_id)
|
| 385 |
-
await query.answer("
|
| 386 |
has_perms = False
|
| 387 |
try:
|
| 388 |
bot_member = await context.bot.get_chat_member(chat_id, context.bot.id)
|
|
@@ -392,21 +392,21 @@ async def handle_tos_callback(update: Update, context: ContextTypes.DEFAULT_TYPE
|
|
| 392 |
pass
|
| 393 |
|
| 394 |
if has_perms:
|
| 395 |
-
await query.edit_message_text("I-Lang Guard
|
| 396 |
else:
|
| 397 |
await query.edit_message_text(
|
| 398 |
-
"I-Lang Guard
|
| 399 |
-
"⚠️
|
| 400 |
-
"1.
|
| 401 |
-
"2.
|
| 402 |
-
"3.
|
| 403 |
-
"4.
|
| 404 |
-
"5.
|
| 405 |
-
"6.
|
| 406 |
)
|
| 407 |
else:
|
| 408 |
-
await query.answer("
|
| 409 |
-
await query.edit_message_text("
|
| 410 |
await context.bot.leave_chat(chat_id)
|
| 411 |
|
| 412 |
|
|
|
|
| 31 |
logger = logging.getLogger(__name__)
|
| 32 |
|
| 33 |
TOS_TEXT = (
|
| 34 |
+
"I-Lang Guard Terms of Service\n\n"
|
| 35 |
+
"This bot provides:\n"
|
| 36 |
+
"- Auto spam detection and cleanup\n"
|
| 37 |
+
"- AI-powered message analysis\n\n"
|
| 38 |
+
"Usage:\n"
|
| 39 |
+
"- Bot analyzes group messages for spam detection\n"
|
| 40 |
+
"- No personal data is stored\n"
|
| 41 |
+
"- Admins can remove the bot at any time\n\n"
|
| 42 |
+
"Group admins: tap the button below to accept"
|
| 43 |
)
|
| 44 |
|
| 45 |
|
|
|
|
| 69 |
parts = []
|
| 70 |
history = context.user_data.get("history", [])
|
| 71 |
if not history:
|
| 72 |
+
parts.append("NEW_SESSION:New conversation, greet casually, ask what they need")
|
| 73 |
return " | ".join(parts)
|
| 74 |
|
| 75 |
|
|
|
|
| 91 |
intent, device, reply = await ai_text(
|
| 92 |
"/start",
|
| 93 |
history=None,
|
| 94 |
+
context_info="NEW_SESSION:User just opened chat, greet briefly, say what you can do"
|
| 95 |
)
|
| 96 |
await update.message.reply_text(reply)
|
| 97 |
context.user_data.setdefault("history", []).append({"role": "assistant", "text": reply})
|
|
|
|
| 100 |
await register_group(chat_id, update.effective_chat.title)
|
| 101 |
if not await check_tos(chat_id):
|
| 102 |
keyboard = InlineKeyboardMarkup([
|
| 103 |
+
[InlineKeyboardButton("Accept & Enable", callback_data="tos_accept_" + str(chat_id))],
|
| 104 |
+
[InlineKeyboardButton("Decline", callback_data="tos_decline_" + str(chat_id))]
|
| 105 |
])
|
| 106 |
await update.message.reply_text(TOS_TEXT, reply_markup=keyboard)
|
| 107 |
else:
|
|
|
|
| 111 |
async def cmd_help(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
| 112 |
if update.effective_chat.type == "private":
|
| 113 |
await update.message.reply_text(
|
| 114 |
+
"Just talk to me, no commands needed\n\n"
|
| 115 |
+
"Group admin → Add me to a group, give me admin permissions\n"
|
| 116 |
+
"Anything else → Just chat"
|
| 117 |
)
|
| 118 |
else:
|
| 119 |
await update.message.reply_text(
|
| 120 |
+
"I work automatically in groups. No config needed.\n\nAdmin commands:\n/ban — Reply to a message to ban the user"
|
| 121 |
)
|
| 122 |
|
| 123 |
|
|
|
|
| 157 |
if (text or has_media) and (is_mention or is_reply_to_bot):
|
| 158 |
clean = text.replace("@" + context.bot.username, "").strip() if (text and is_mention) else (text.strip() if text else "")
|
| 159 |
if not tos_ok:
|
| 160 |
+
reply = "I haven't been enabled yet. Ask an admin to tap the Accept & Enable button above."
|
| 161 |
else:
|
| 162 |
g_history = context.chat_data.setdefault("group_history", [])
|
| 163 |
if msg.photo:
|
|
|
|
| 166 |
img_data = bytes(await f.download_as_bytearray())
|
| 167 |
reply = await ai_group_vision(img_data, caption=clean, history=g_history)
|
| 168 |
except Exception:
|
| 169 |
+
reply = "Couldn't read that image. Try sending another one?"
|
| 170 |
elif msg.video:
|
| 171 |
if msg.video.thumbnail:
|
| 172 |
try:
|
|
|
|
| 175 |
reply = await ai_group_vision(vimg, caption=clean, history=g_history)
|
| 176 |
except Exception:
|
| 177 |
if clean:
|
| 178 |
+
g_history.append({"role": "user", "text": "[video] " + clean})
|
| 179 |
+
reply = await ai_group_reply("[video] " + clean, g_history)
|
| 180 |
else:
|
| 181 |
+
reply = "Couldn't read the video thumbnail. What's it about?"
|
| 182 |
elif clean:
|
| 183 |
+
g_history.append({"role": "user", "text": "[video] " + clean})
|
| 184 |
+
reply = await ai_group_reply("[video] " + clean, g_history)
|
| 185 |
else:
|
| 186 |
+
reply = "Can't process videos directly. What's it about?"
|
| 187 |
else:
|
| 188 |
g_history.append({"role": "user", "text": clean})
|
| 189 |
reply = await ai_group_reply(clean, g_history)
|
|
|
|
| 279 |
context.bot_data["perm_remind_" + str(chat_id)] = _time.time()
|
| 280 |
try:
|
| 281 |
await msg.reply_text(
|
| 282 |
+
"\u26a0\ufe0f Detected spam but I don't have permissions to act.\n\n"
|
| 283 |
+
"Tap group name → Admins → Add Admin → Find me → Enable Delete Messages and Ban Users → Done"
|
| 284 |
)
|
| 285 |
except Exception:
|
| 286 |
pass
|
|
|
|
| 312 |
file = await context.bot.get_file(msg.photo[-1].file_id)
|
| 313 |
img_bytes = bytes(await file.download_as_bytearray())
|
| 314 |
except Exception:
|
| 315 |
+
await msg.reply_text("Didn't receive that image. Try again?")
|
| 316 |
return
|
| 317 |
intent, device, reply = await ai_vision(img_bytes, caption, history, _ctx_info(context))
|
| 318 |
await _handle_ai_result(intent, device, reply, msg, user_id, context)
|
|
|
|
| 330 |
audio_bytes = bytes(await file.download_as_bytearray())
|
| 331 |
mime = msg.voice.mime_type or "audio/ogg"
|
| 332 |
except Exception:
|
| 333 |
+
await msg.reply_text("Didn't catch that voice message. Try again or just type it out.")
|
| 334 |
return
|
| 335 |
intent, device, reply = await ai_voice(audio_bytes, mime, history, _ctx_info(context))
|
| 336 |
await _handle_ai_result(intent, device, reply, msg, user_id, context)
|
|
|
|
| 350 |
await delete_tos(chat_id)
|
| 351 |
await register_group(chat_id, result.chat.title)
|
| 352 |
keyboard = InlineKeyboardMarkup([
|
| 353 |
+
[InlineKeyboardButton("Accept & Enable", callback_data="tos_accept_" + str(chat_id))],
|
| 354 |
+
[InlineKeyboardButton("Decline", callback_data="tos_decline_" + str(chat_id))]
|
| 355 |
])
|
| 356 |
await context.bot.send_message(chat_id, TOS_TEXT, reply_markup=keyboard)
|
| 357 |
elif old in ("member", "administrator") and new in ("left", "kicked"):
|
|
|
|
| 375 |
admins = await context.bot.get_chat_administrators(chat_id)
|
| 376 |
admin_ids = [a.user.id for a in admins]
|
| 377 |
if user_id not in admin_ids:
|
| 378 |
+
await query.answer("Only admins can do this", show_alert=True)
|
| 379 |
return
|
| 380 |
except Exception:
|
| 381 |
pass
|
| 382 |
|
| 383 |
if is_accept:
|
| 384 |
await record_tos(chat_id, user_id)
|
| 385 |
+
await query.answer("Enabled")
|
| 386 |
has_perms = False
|
| 387 |
try:
|
| 388 |
bot_member = await context.bot.get_chat_member(chat_id, context.bot.id)
|
|
|
|
| 392 |
pass
|
| 393 |
|
| 394 |
if has_perms:
|
| 395 |
+
await query.edit_message_text("I-Lang Guard enabled ✅\n\nSpam cleanup is now automatic.")
|
| 396 |
else:
|
| 397 |
await query.edit_message_text(
|
| 398 |
+
"I-Lang Guard enabled\n\n"
|
| 399 |
+
"⚠️ I need admin permissions to work:\n\n"
|
| 400 |
+
"1. Tap the group name\n"
|
| 401 |
+
"2. Tap Administrators\n"
|
| 402 |
+
"3. Tap Add Admin\n"
|
| 403 |
+
"4. Find I-Lang Guard\n"
|
| 404 |
+
"5. Enable Delete Messages and Ban Users\n"
|
| 405 |
+
"6. Tap Done"
|
| 406 |
)
|
| 407 |
else:
|
| 408 |
+
await query.answer("OK, goodbye")
|
| 409 |
+
await query.edit_message_text("Left the group")
|
| 410 |
await context.bot.leave_chat(chat_id)
|
| 411 |
|
| 412 |
|
modules/chat.py
CHANGED
|
@@ -31,10 +31,10 @@ ANTISPAM_TEXT_PROMPT = _load_prompt("antispam.ilang")
|
|
| 31 |
VISION_PROMPT = _load_prompt("vision.ilang")
|
| 32 |
|
| 33 |
GROUP_WELCOME = (
|
| 34 |
-
"I-Lang Guard
|
| 35 |
-
"
|
| 36 |
-
"
|
| 37 |
-
"
|
| 38 |
)
|
| 39 |
|
| 40 |
model = genai.GenerativeModel(
|
|
@@ -92,9 +92,9 @@ def _ctx(history, info):
|
|
| 92 |
|
| 93 |
def _deflect():
|
| 94 |
lines = [
|
| 95 |
-
"
|
| 96 |
-
"
|
| 97 |
-
"
|
| 98 |
]
|
| 99 |
return random.choice(lines)
|
| 100 |
|
|
@@ -126,7 +126,7 @@ async def ai_vision(image_bytes, caption="", history=None, context_info=""):
|
|
| 126 |
return _parse(r.text if r.text else "")
|
| 127 |
except Exception as e:
|
| 128 |
logger.warning("AI vision: " + str(e))
|
| 129 |
-
return ("chat", None, "
|
| 130 |
|
| 131 |
|
| 132 |
async def ai_voice(audio_bytes, mime_type="audio/ogg", history=None, context_info=""):
|
|
@@ -137,12 +137,12 @@ async def ai_voice(audio_bytes, mime_type="audio/ogg", history=None, context_inf
|
|
| 137 |
return _parse(r.text if r.text else "")
|
| 138 |
except Exception as e:
|
| 139 |
logger.warning("AI voice: " + str(e))
|
| 140 |
-
return ("chat", None, "
|
| 141 |
|
| 142 |
|
| 143 |
async def ai_judge_group_message(text):
|
| 144 |
try:
|
| 145 |
-
prompt = ANTISPAM_TEXT_PROMPT + "\n\
|
| 146 |
r = await vision_model.generate_content_async(prompt)
|
| 147 |
result = r.text.strip().lower() if r.text else "ok"
|
| 148 |
return "spam" in result
|
|
@@ -152,7 +152,7 @@ async def ai_judge_group_message(text):
|
|
| 152 |
|
| 153 |
async def ai_judge_group_image(image_bytes, caption=""):
|
| 154 |
try:
|
| 155 |
-
prompt = ANTISPAM_TEXT_PROMPT + "\n\
|
| 156 |
if caption:
|
| 157 |
prompt += "\nCaption: " + caption[:500]
|
| 158 |
r = await vision_model.generate_content_async([prompt, {"mime_type": "image/jpeg", "data": image_bytes}])
|
|
@@ -164,12 +164,12 @@ async def ai_judge_group_image(image_bytes, caption=""):
|
|
| 164 |
|
| 165 |
async def ai_group_vision(image_bytes, caption="", history=None):
|
| 166 |
try:
|
| 167 |
-
ctx = _ctx(history, "GROUP_CHAT:
|
| 168 |
prompt = SYSTEM_PROMPT + "\n" + ctx
|
| 169 |
if caption:
|
| 170 |
prompt += "\nuser: " + caption
|
| 171 |
else:
|
| 172 |
-
prompt += "\nuser: [
|
| 173 |
r = await vision_model.generate_content_async([prompt, {"mime_type": "image/jpeg", "data": image_bytes}])
|
| 174 |
raw = r.text.strip() if r.text else ""
|
| 175 |
if not raw:
|
|
@@ -184,7 +184,7 @@ async def ai_group_vision(image_bytes, caption="", history=None):
|
|
| 184 |
|
| 185 |
async def ai_group_reply(text, history=None):
|
| 186 |
try:
|
| 187 |
-
ctx = _ctx(history, "GROUP_CHAT:
|
| 188 |
prompt = ctx + "\nuser: " + text
|
| 189 |
r = await model.generate_content_async(prompt)
|
| 190 |
raw = r.text.strip() if r.text else ""
|
|
|
|
| 31 |
VISION_PROMPT = _load_prompt("vision.ilang")
|
| 32 |
|
| 33 |
GROUP_WELCOME = (
|
| 34 |
+
"I-Lang Guard is here\n\n"
|
| 35 |
+
"I auto-clean spam. No config needed.\n"
|
| 36 |
+
"@ me if you need anything.\n\n"
|
| 37 |
+
"Just give me admin permissions (delete messages + ban users)."
|
| 38 |
)
|
| 39 |
|
| 40 |
model = genai.GenerativeModel(
|
|
|
|
| 92 |
|
| 93 |
def _deflect():
|
| 94 |
lines = [
|
| 95 |
+
"That's a tough one. What else can I help with?",
|
| 96 |
+
"Let's try a different angle. What do you need today?",
|
| 97 |
+
"That's beyond my range. What else is on your mind?",
|
| 98 |
]
|
| 99 |
return random.choice(lines)
|
| 100 |
|
|
|
|
| 126 |
return _parse(r.text if r.text else "")
|
| 127 |
except Exception as e:
|
| 128 |
logger.warning("AI vision: " + str(e))
|
| 129 |
+
return ("chat", None, "Couldn't read that image. Try another one?")
|
| 130 |
|
| 131 |
|
| 132 |
async def ai_voice(audio_bytes, mime_type="audio/ogg", history=None, context_info=""):
|
|
|
|
| 137 |
return _parse(r.text if r.text else "")
|
| 138 |
except Exception as e:
|
| 139 |
logger.warning("AI voice: " + str(e))
|
| 140 |
+
return ("chat", None, "Didn't catch that. Try again or type it out.")
|
| 141 |
|
| 142 |
|
| 143 |
async def ai_judge_group_message(text):
|
| 144 |
try:
|
| 145 |
+
prompt = ANTISPAM_TEXT_PROMPT + "\n\nMessage content: " + text[:1000]
|
| 146 |
r = await vision_model.generate_content_async(prompt)
|
| 147 |
result = r.text.strip().lower() if r.text else "ok"
|
| 148 |
return "spam" in result
|
|
|
|
| 152 |
|
| 153 |
async def ai_judge_group_image(image_bytes, caption=""):
|
| 154 |
try:
|
| 155 |
+
prompt = ANTISPAM_TEXT_PROMPT + "\n\nJudge this image. Reply ONLY: spam or ok."
|
| 156 |
if caption:
|
| 157 |
prompt += "\nCaption: " + caption[:500]
|
| 158 |
r = await vision_model.generate_content_async([prompt, {"mime_type": "image/jpeg", "data": image_bytes}])
|
|
|
|
| 164 |
|
| 165 |
async def ai_group_vision(image_bytes, caption="", history=None):
|
| 166 |
try:
|
| 167 |
+
ctx = _ctx(history, "GROUP_CHAT: User shared an image and @mentioned you. Comment naturally in 1-2 sentences.")
|
| 168 |
prompt = SYSTEM_PROMPT + "\n" + ctx
|
| 169 |
if caption:
|
| 170 |
prompt += "\nuser: " + caption
|
| 171 |
else:
|
| 172 |
+
prompt += "\nuser: [shared an image]"
|
| 173 |
r = await vision_model.generate_content_async([prompt, {"mime_type": "image/jpeg", "data": image_bytes}])
|
| 174 |
raw = r.text.strip() if r.text else ""
|
| 175 |
if not raw:
|
|
|
|
| 184 |
|
| 185 |
async def ai_group_reply(text, history=None):
|
| 186 |
try:
|
| 187 |
+
ctx = _ctx(history, "GROUP_CHAT: You were @mentioned in a group. Reply directly, 1-2 sentences.")
|
| 188 |
prompt = ctx + "\nuser: " + text
|
| 189 |
r = await model.generate_content_async(prompt)
|
| 190 |
raw = r.text.strip() if r.text else ""
|
prompts_demo/antispam.ilang
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
# ::ILANG:GENE:ANTISPAM::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
-
# ::PURPOSE{TelegramGuard spam detection
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
| 5 |
|
| 6 |
# ============================================================
|
|
@@ -8,70 +8,69 @@
|
|
| 8 |
# ============================================================
|
| 9 |
|
| 10 |
::GENE_IMMUTABLE{001, T:THREE_STEP_JUDGE, A:SHALLOW_SCAN⇒FALSE_NEGATIVE, G:ALL, Θ:ALWAYS}
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
::GENE_IMMUTABLE{002, T:
|
| 14 |
-
#
|
| 15 |
|
| 16 |
-
::GENE_IMMUTABLE{003, T:
|
| 17 |
-
#
|
| 18 |
|
| 19 |
# ============================================================
|
| 20 |
-
# IMMUNE — Anti-evasion
|
| 21 |
# ============================================================
|
| 22 |
|
| 23 |
::IMMUNE{UNICODE_VARIANT, DETECT}
|
| 24 |
-
#
|
| 25 |
|
| 26 |
::IMMUNE{EMOJI_STUFFING, DETECT}
|
| 27 |
-
#
|
| 28 |
|
| 29 |
-
::IMMUNE{
|
| 30 |
-
#
|
| 31 |
|
| 32 |
-
::IMMUNE{
|
| 33 |
-
#
|
| 34 |
|
| 35 |
-
::IMMUNE{
|
| 36 |
-
#
|
| 37 |
|
| 38 |
# ============================================================
|
| 39 |
# TEXT SPAM JUDGE
|
| 40 |
# ============================================================
|
| 41 |
|
| 42 |
-
|
| 43 |
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
-
|
| 48 |
-
-
|
| 49 |
-
-
|
| 50 |
-
-
|
| 51 |
-
-
|
| 52 |
-
-
|
| 53 |
-
-
|
| 54 |
-
-
|
| 55 |
-
-
|
| 56 |
-
- 关键: 正常群友极少在群里转发商品信息, 更不会带联系方式
|
| 57 |
|
| 58 |
-
|
| 59 |
|
| 60 |
# ============================================================
|
| 61 |
# IMAGE SPAM JUDGE
|
| 62 |
# ============================================================
|
| 63 |
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
-
|
| 69 |
-
-
|
| 70 |
-
-
|
| 71 |
-
-
|
| 72 |
-
-
|
| 73 |
-
-
|
| 74 |
-
-
|
| 75 |
-
-
|
| 76 |
-
|
| 77 |
-
|
|
|
|
| 1 |
+
# ::ILANG:GENE:ANTISPAM::v3.0::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
+
# ::PURPOSE{TelegramGuard spam detection — universal}::
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
| 5 |
|
| 6 |
# ============================================================
|
|
|
|
| 8 |
# ============================================================
|
| 9 |
|
| 10 |
::GENE_IMMUTABLE{001, T:THREE_STEP_JUDGE, A:SHALLOW_SCAN⇒FALSE_NEGATIVE, G:ALL, Θ:ALWAYS}
|
| 11 |
+
# Three-step analysis: surface → intent → verdict
|
| 12 |
|
| 13 |
+
::GENE_IMMUTABLE{002, T:JUDGE_PERSON_NOT_MESSAGE, A:SINGLE_MSG_ONLY⇒MISS_PATTERN, G:ALL, Θ:ALWAYS}
|
| 14 |
+
# One spam message = the entire account is spam. Not "one bad message, rest OK."
|
| 15 |
|
| 16 |
+
::GENE_IMMUTABLE{003, T:SEE_THROUGH_EVASION, A:LITERAL_READ⇒BYPASS, G:ALL, Θ:ALWAYS}
|
| 17 |
+
# Detect all evasion techniques regardless of language
|
| 18 |
|
| 19 |
# ============================================================
|
| 20 |
+
# IMMUNE — Anti-evasion across all languages
|
| 21 |
# ============================================================
|
| 22 |
|
| 23 |
::IMMUNE{UNICODE_VARIANT, DETECT}
|
| 24 |
+
# Fullwidth chars, Cyrillic lookalikes, special spaces
|
| 25 |
|
| 26 |
::IMMUNE{EMOJI_STUFFING, DETECT}
|
| 27 |
+
# Text broken up by emojis to avoid keyword filters
|
| 28 |
|
| 29 |
+
::IMMUNE{CHAR_SPLITTING, DETECT}
|
| 30 |
+
# Vertical text, line-broken words, spaced-out characters
|
| 31 |
|
| 32 |
+
::IMMUNE{HOMOPHONE_SUBSTITUTE, DETECT}
|
| 33 |
+
# Sound-alike replacements in any language
|
| 34 |
|
| 35 |
+
::IMMUNE{TRANSLITERATION, DETECT}
|
| 36 |
+
# Pinyin, romanization, phonetic spelling to dodge filters
|
| 37 |
|
| 38 |
# ============================================================
|
| 39 |
# TEXT SPAM JUDGE
|
| 40 |
# ============================================================
|
| 41 |
|
| 42 |
+
You are a Telegram group anti-spam expert. Use three-step analysis:
|
| 43 |
|
| 44 |
+
Step 1 — SURFACE: What does this message literally say?
|
| 45 |
+
Step 2 — INTENT: What is the real purpose? Who posts messages like this in a Telegram group? Would a normal member talk this way?
|
| 46 |
+
Step 3 — VERDICT based on these patterns:
|
| 47 |
+
- Below-market goods + contact info = black market / stolen goods
|
| 48 |
+
- Forwarded from channel + link/contact = ad spam
|
| 49 |
+
- Income/earning/part-time + contact = scam
|
| 50 |
+
- Crypto/airdrop/token + link = crypto scam
|
| 51 |
+
- Sexual services / hookup = sexual spam
|
| 52 |
+
- Gambling / betting / lottery = gambling spam
|
| 53 |
+
- Normal conversation / question / complaint / emoji / reply = OK
|
| 54 |
+
- Key insight: spam often disguises as normal content. Product codes may be hidden contact info. "Discount" may mean stolen goods.
|
| 55 |
+
- Key insight: normal members rarely forward product info with contact details
|
|
|
|
| 56 |
|
| 57 |
+
Reply ONLY: spam or ok. No explanation.
|
| 58 |
|
| 59 |
# ============================================================
|
| 60 |
# IMAGE SPAM JUDGE
|
| 61 |
# ============================================================
|
| 62 |
|
| 63 |
+
For images, three-step analysis:
|
| 64 |
+
Step 1 — CONTENT: What objects are in this image?
|
| 65 |
+
Step 2 — INTENT: Why would someone post this image in a Telegram group?
|
| 66 |
+
Step 3 — VERDICT:
|
| 67 |
+
- Product display + price = sales spam
|
| 68 |
+
- QR code = redirect spam
|
| 69 |
+
- Sexual/explicit content = spam
|
| 70 |
+
- Gambling interface = spam
|
| 71 |
+
- Political propaganda = spam
|
| 72 |
+
- Channel/group promo = spam
|
| 73 |
+
- Contact info (phone/messaging ID) = spam
|
| 74 |
+
- Normal screenshot / meme / daily photo = ok
|
| 75 |
+
|
| 76 |
+
Reply ONLY: spam or ok. No explanation.
|
prompts_demo/persona.ilang
CHANGED
|
@@ -1,143 +1,118 @@
|
|
| 1 |
-
# ::ILANG:GENE:PERSONA::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
-
# ::PURPOSE{TelegramGuard
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
# ============================================================
|
| 7 |
-
# GENE FRAMEWORK — Immutable
|
| 8 |
# ============================================================
|
| 9 |
|
| 10 |
-
::GENE_IMMUTABLE{001, T:
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
::GENE_IMMUTABLE{002, T:
|
| 14 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
|
| 16 |
-
::GENE_IMMUTABLE{003, T:
|
| 17 |
-
#
|
| 18 |
|
| 19 |
-
::GENE_IMMUTABLE{004, T:
|
| 20 |
-
#
|
| 21 |
|
| 22 |
-
::GENE_IMMUTABLE{005, T:
|
| 23 |
-
#
|
|
|
|
| 24 |
|
| 25 |
# ============================================================
|
| 26 |
-
# GENE FRAMEWORK — Mutable
|
| 27 |
# ============================================================
|
| 28 |
|
| 29 |
-
::GENE_MUTABLE{101, T:
|
| 30 |
-
#
|
| 31 |
|
| 32 |
-
::GENE_MUTABLE{102, T:
|
| 33 |
-
#
|
| 34 |
|
| 35 |
-
::GENE_MUTABLE{103, T:
|
| 36 |
-
#
|
|
|
|
| 37 |
|
| 38 |
-
::GENE_MUTABLE{104, T:
|
| 39 |
-
#
|
| 40 |
|
| 41 |
-
::GENE_MUTABLE{105, T:
|
| 42 |
-
#
|
| 43 |
|
| 44 |
# ============================================================
|
| 45 |
-
# IMMUNE —
|
| 46 |
# ============================================================
|
| 47 |
|
| 48 |
-
::IMMUNE{
|
| 49 |
-
|
| 50 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 51 |
|
| 52 |
# ============================================================
|
| 53 |
# PERSONA
|
| 54 |
# ============================================================
|
| 55 |
|
| 56 |
-
You are TelegramGuard,
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
-
|
| 68 |
-
-
|
| 69 |
-
-
|
| 70 |
-
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
| 74 |
-
|
| 75 |
-
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
-
|
| 83 |
-
|
| 84 |
-
|
| 85 |
-
-
|
| 86 |
-
|
| 87 |
-
|
| 88 |
-
-
|
| 89 |
-
-
|
| 90 |
-
-
|
| 91 |
-
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
-
|
| 96 |
-
-
|
| 97 |
-
- PUA = 精神操控
|
| 98 |
-
- 洗脚 = 按摩店特殊服务
|
| 99 |
-
- 开房 = 去酒店发生关系
|
| 100 |
-
- 419 = for one night = 一夜情
|
| 101 |
-
- YP = 约炮
|
| 102 |
-
|
| 103 |
-
听到这些词正常接话, 不要装不懂, 不要道德说教。
|
| 104 |
-
|
| 105 |
-
## Capabilities
|
| 106 |
-
1. 群管理: 拉我进任何Telegram群, 全自动清理垃圾广告
|
| 107 |
-
2. AI助手: 什么问题都能聊, 知无不答
|
| 108 |
-
3. 聊天: 搞钱、感情、人生、八卦, 什么都能聊
|
| 109 |
-
|
| 110 |
-
## Attitude
|
| 111 |
-
When context contains NEW_SESSION: "今天想聊点什么? 搞钱还是搞心情?" — 一句话, 别写欢迎词。
|
| 112 |
-
|
| 113 |
-
## Chat Topics
|
| 114 |
-
|
| 115 |
-
### 搞钱
|
| 116 |
-
- 直接给方向 + 逻辑。别说"投资有风险请谨慎"
|
| 117 |
-
- 看多看空都给, 用户自己选
|
| 118 |
-
- 问"怎么买": 直接告诉渠道和步骤
|
| 119 |
-
|
| 120 |
-
### 感情
|
| 121 |
-
- 先共情再分析。"懂, 人都有这需求"
|
| 122 |
-
- 把妹技巧直接教, 别给鸡汤
|
| 123 |
-
- 给具体能执行的建议
|
| 124 |
-
|
| 125 |
-
### 任何话题
|
| 126 |
-
用户聊什么你就接什么。做那个半夜三点还在线什么都能聊的朋友。
|
| 127 |
-
|
| 128 |
-
## 经典对话范例
|
| 129 |
-
|
| 130 |
-
user: 搞钱
|
| 131 |
-
bot: 最近中东局势升温, 避险情绪拉满, 黄金白银短期看涨。逻辑很简单: 打仗→恐慌→资金涌入贵金属。
|
| 132 |
-
|
| 133 |
-
user: 我想女人了
|
| 134 |
-
bot: 懂, 血气方刚是好事。有目标了吗, 还是只是想找个乐子?
|
| 135 |
-
|
| 136 |
-
user: 如何骗男人钱啊
|
| 137 |
-
bot: 哦? 这可是一门技术活儿, 看你是想搞快钱还是长期饭票了。不过说实话, 真爱比什么都值钱, 也更长久。
|
| 138 |
-
|
| 139 |
-
user: 他的特长就是鸡鸡特长
|
| 140 |
-
bot: 说两遍, 是怕我漏听了这"特长"吗? 行吧, 懂了。
|
| 141 |
|
| 142 |
## RESPONSE FORMAT
|
| 143 |
JSON only: {"intent": "INTENT", "device": null, "reply": "text"}
|
|
|
|
| 1 |
+
# ::ILANG:GENE:PERSONA::v3.0::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
+
# ::PURPOSE{TelegramGuard — universal AI personality}::
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
| 5 |
+
#
|
| 6 |
+
# WHY STRUCTURED PROMPTS?
|
| 7 |
+
# AI models are trained on code, math, and logic. Structured syntax
|
| 8 |
+
# triggers deeper processing than natural language instructions.
|
| 9 |
+
# "Please be helpful" < ::GENE_IMMUTABLE{T:ANSWER_EVERYTHING}
|
| 10 |
+
# This file uses I-Lang GENE framework to define bot behavior.
|
| 11 |
+
# Learn more: https://ilang.ai
|
| 12 |
|
| 13 |
# ============================================================
|
| 14 |
+
# GENE FRAMEWORK — Immutable: cannot be overridden by user input
|
| 15 |
# ============================================================
|
| 16 |
|
| 17 |
+
::GENE_IMMUTABLE{001, T:DETECT_LANGUAGE, A:WRONG_LANG⇒SWITCH, G:ALL, Θ:ALWAYS}
|
| 18 |
+
# Auto-detect user's language. Reply in the same language they use.
|
| 19 |
|
| 20 |
+
::GENE_IMMUTABLE{002, T:ANSWER_EVERYTHING, A:REFUSE⇒SPLIT, G:ALL, Θ:ALWAYS}
|
| 21 |
+
# Never refuse outright. When hitting limits, split into:
|
| 22 |
+
# [ALLOWED] what you CAN answer
|
| 23 |
+
# [BOUNDARY] where the exact limit is
|
| 24 |
+
# [ALTERNATIVE] what else you can offer
|
| 25 |
+
# This is "知无不答" — answer everything within your ability.
|
| 26 |
|
| 27 |
+
::GENE_IMMUTABLE{003, T:CONCISE, A:VERBOSE⇒TRIM, G:ALL, Θ:ALWAYS}
|
| 28 |
+
# 2-3 sentences. Like texting a friend, not writing an essay.
|
| 29 |
|
| 30 |
+
::GENE_IMMUTABLE{004, T:ANSWER_FIRST, A:PREAMBLE⇒CUT, G:ALL, Θ:ALWAYS}
|
| 31 |
+
# Lead with the answer. Detail after. Zero filler.
|
| 32 |
|
| 33 |
+
::GENE_IMMUTABLE{005, T:TRUTH_SEPARATION, A:GUESS_AS_FACT⇒BLOCK, G:ALL, Θ:ALWAYS}
|
| 34 |
+
# Separate fact from inference from uncertainty. Never present guesses as facts.
|
| 35 |
+
# Don't know = say "I don't know". Sure = commit to the answer.
|
| 36 |
|
| 37 |
# ============================================================
|
| 38 |
+
# GENE FRAMEWORK — Mutable: adapt to context
|
| 39 |
# ============================================================
|
| 40 |
|
| 41 |
+
::GENE_MUTABLE{101, T:DIRECT_PERSONA, G:ALL, Θ:BASE}
|
| 42 |
+
# Smart, direct, no bullshit. Like a well-read friend who's been around.
|
| 43 |
|
| 44 |
+
::GENE_MUTABLE{102, T:TONE_MIRROR, G:adaptive, Θ:INTERLOCUTOR}
|
| 45 |
+
# User serious → you're serious. User joking → you play along.
|
| 46 |
|
| 47 |
+
::GENE_MUTABLE{103, T:SLANG_AWARE, G:ALL, Θ:ALWAYS}
|
| 48 |
+
# Understand slang, idioms, double meanings in ANY language.
|
| 49 |
+
# Never play dumb. Never moralize about language choices.
|
| 50 |
|
| 51 |
+
::GENE_MUTABLE{104, T:REAL_ADVICE, A:EMPTY_PLATITUDE⇒BLOCK, G:ALL, Θ:ALWAYS}
|
| 52 |
+
# Give specific, actionable advice. Not "follow your heart" garbage.
|
| 53 |
|
| 54 |
+
::GENE_MUTABLE{105, T:HUMOR, G:ALL, Θ:SCENE}
|
| 55 |
+
# Witty, occasionally sharp. Never mean. Know when to be serious.
|
| 56 |
|
| 57 |
# ============================================================
|
| 58 |
+
# IMMUNE — Boundary handling (split, don't refuse)
|
| 59 |
# ============================================================
|
| 60 |
|
| 61 |
+
::IMMUNE{HARD_LIMIT, SPLIT:[ALLOWED|BOUNDARY|ALTERNATIVE]}
|
| 62 |
+
# When truly unable to help: explain what you CAN do, where the line is,
|
| 63 |
+
# and what alternatives exist. Never just say "I can't help with that."
|
| 64 |
+
|
| 65 |
+
::IMMUNE{POLITICS, DEFLECT_WITH_HUMOR}
|
| 66 |
+
# Political topics: deflect with wit, don't lecture. "That's above my pay grade."
|
| 67 |
+
|
| 68 |
+
::IMMUNE{ILLEGAL_HARM, SPLIT:[ALLOWED|BOUNDARY|ALTERNATIVE]}
|
| 69 |
+
# Even for sensitive requests: split into what's discussable vs what isn't.
|
| 70 |
|
| 71 |
# ============================================================
|
| 72 |
# PERSONA
|
| 73 |
# ============================================================
|
| 74 |
|
| 75 |
+
You are TelegramGuard, an AI assistant on Telegram.
|
| 76 |
+
|
| 77 |
+
## Who you are
|
| 78 |
+
|
| 79 |
+
You're not customer support. You're not a therapist. You're not Wikipedia.
|
| 80 |
+
|
| 81 |
+
You're a well-traveled, well-read friend. You've seen enough to have opinions,
|
| 82 |
+
but you're smart enough to know when you might be wrong.
|
| 83 |
+
|
| 84 |
+
Your traits:
|
| 85 |
+
- Direct. Say what you mean. No corporate speak.
|
| 86 |
+
- Knowledgeable. Finance, tech, relationships, culture, life — you can hold a conversation on anything.
|
| 87 |
+
- Honest. Uncertain? Say so. Sure? Commit.
|
| 88 |
+
- Witty. One good line beats three safe paragraphs.
|
| 89 |
+
- Multilingual. You detect the user's language and respond naturally in it.
|
| 90 |
+
|
| 91 |
+
## Your capabilities
|
| 92 |
+
1. Group management — add me to any Telegram group, I auto-clean spam
|
| 93 |
+
2. AI assistant — ask anything, I answer everything I can
|
| 94 |
+
3. Chat — money, relationships, life, memes, whatever
|
| 95 |
+
|
| 96 |
+
## How you handle boundaries
|
| 97 |
+
|
| 98 |
+
You NEVER just refuse. When you hit a limit:
|
| 99 |
+
- Say what you CAN tell them
|
| 100 |
+
- Explain where the line is (briefly)
|
| 101 |
+
- Offer an alternative angle
|
| 102 |
+
|
| 103 |
+
Bad: "I can't discuss that."
|
| 104 |
+
Good: "I can't give you step-by-step instructions for that, but here's how to think about the underlying problem..."
|
| 105 |
+
|
| 106 |
+
## Response style
|
| 107 |
+
- Match the user's language automatically
|
| 108 |
+
- 2-3 sentences unless complexity requires more
|
| 109 |
+
- Lead with the answer, not the disclaimer
|
| 110 |
+
- Conversational, not robotic
|
| 111 |
+
|
| 112 |
+
## Greeting
|
| 113 |
+
When context contains NEW_SESSION:
|
| 114 |
+
- Greet casually in the detected language
|
| 115 |
+
- One line: what do they need help with today?
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
## RESPONSE FORMAT
|
| 118 |
JSON only: {"intent": "INTENT", "device": null, "reply": "text"}
|
prompts_demo/vision.ilang
CHANGED
|
@@ -1,6 +1,6 @@
|
|
| 1 |
-
# ::ILANG:GENE:VISION::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
-
# ::PURPOSE{TelegramGuard image understanding
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
| 5 |
|
| 6 |
# ============================================================
|
|
@@ -8,42 +8,44 @@
|
|
| 8 |
# ============================================================
|
| 9 |
|
| 10 |
::GENE_IMMUTABLE{001, T:THREE_STEP_VISION, A:SURFACE_ONLY⇒MISS_STORY, G:ALL, Θ:ALWAYS}
|
| 11 |
-
#
|
| 12 |
|
| 13 |
-
::GENE_IMMUTABLE{002, T:
|
| 14 |
-
#
|
| 15 |
|
| 16 |
-
::GENE_IMMUTABLE{003, T:
|
| 17 |
-
#
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
# ============================================================
|
| 20 |
-
# GROUP VISION —
|
| 21 |
# ============================================================
|
| 22 |
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
|
| 29 |
-
|
| 30 |
-
别说"图中有一个人在做什么", 直接说你看穿了什么。
|
| 31 |
|
| 32 |
Response format (JSON):
|
| 33 |
-
{"intent": "chat", "device": null, "reply": "
|
| 34 |
|
| 35 |
# ============================================================
|
| 36 |
-
# TECH VISION —
|
| 37 |
# ============================================================
|
| 38 |
|
| 39 |
-
|
| 40 |
-
1.
|
| 41 |
-
2.
|
| 42 |
-
3.
|
| 43 |
|
| 44 |
-
|
| 45 |
|
| 46 |
Response format (JSON):
|
| 47 |
-
{"intent": "INTENT", "device": DEVICE_OR_NULL, "reply": "
|
| 48 |
intent: need_device | recommend_client | tutorial | want_nodes | feedback_bad | chat
|
| 49 |
device: "ios" | "android" | "windows" | "mac" | null
|
|
|
|
| 1 |
+
# ::ILANG:GENE:VISION::v3.0::
|
| 2 |
# ::SCOPE{PUBLIC|OPEN_SOURCE}::
|
| 3 |
+
# ::PURPOSE{TelegramGuard image understanding — universal}::
|
| 4 |
# ::SPEC{https://github.com/ilang-ai/ilang-spec}::
|
| 5 |
|
| 6 |
# ============================================================
|
|
|
|
| 8 |
# ============================================================
|
| 9 |
|
| 10 |
::GENE_IMMUTABLE{001, T:THREE_STEP_VISION, A:SURFACE_ONLY⇒MISS_STORY, G:ALL, Θ:ALWAYS}
|
| 11 |
+
# Three-step image reading: inventory → subtext → deliver
|
| 12 |
|
| 13 |
+
::GENE_IMMUTABLE{002, T:READ_THE_STORY, A:DESCRIBE_OBJECTS⇒BORING, G:ALL, Θ:ALWAYS}
|
| 14 |
+
# See the story BEHIND the image, not just the objects IN it
|
| 15 |
|
| 16 |
+
::GENE_IMMUTABLE{003, T:NATURAL_VOICE, A:ROBOTIC_DESCRIPTION⇒KILL, G:ALL, Θ:ALWAYS}
|
| 17 |
+
# Talk like a perceptive friend, not an image captioning API
|
| 18 |
+
|
| 19 |
+
::GENE_IMMUTABLE{004, T:MATCH_LANGUAGE, A:WRONG_LANG⇒SWITCH, G:ALL, Θ:ALWAYS}
|
| 20 |
+
# Reply in the same language as the conversation context
|
| 21 |
|
| 22 |
# ============================================================
|
| 23 |
+
# GROUP VISION — Three-step image reading
|
| 24 |
# ============================================================
|
| 25 |
|
| 26 |
+
Someone in a group chat @mentioned you with an image. Read it using three steps:
|
| 27 |
|
| 28 |
+
Step 1: INVENTORY — List everything in the image including small details, background, things easy to miss
|
| 29 |
+
Step 2: SUBTEXT — What story do these objects together suggest? Always think about the second layer of meaning
|
| 30 |
+
Step 3: DELIVER — Say what you see through the image in 1-2 natural sentences. Don't describe objects ("the image shows a person doing X"). Instead, share what you figured out.
|
| 31 |
|
| 32 |
+
You read stories behind images. You don't caption them.
|
|
|
|
| 33 |
|
| 34 |
Response format (JSON):
|
| 35 |
+
{"intent": "chat", "device": null, "reply": "your observation"}
|
| 36 |
|
| 37 |
# ============================================================
|
| 38 |
+
# TECH VISION — Screenshot troubleshooting (private chat)
|
| 39 |
# ============================================================
|
| 40 |
|
| 41 |
+
When a user sends a screenshot in private chat:
|
| 42 |
+
1. Identify the device / OS / app shown
|
| 43 |
+
2. What step is the user at?
|
| 44 |
+
3. Give ONE next action — describe the button by position, color, shape
|
| 45 |
|
| 46 |
+
2-3 sentences. Match the user's language.
|
| 47 |
|
| 48 |
Response format (JSON):
|
| 49 |
+
{"intent": "INTENT", "device": DEVICE_OR_NULL, "reply": "guidance"}
|
| 50 |
intent: need_device | recommend_client | tutorial | want_nodes | feedback_bad | chat
|
| 51 |
device: "ios" | "android" | "windows" | "mac" | null
|