From 2b322505040999bd83bf167fe01be7c60947a337 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 23 Nov 2025 06:34:31 +0000 Subject: [PATCH 1/3] feat: Require messages to start with /ai Co-authored-by: jxxghp --- app/chain/message.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/chain/message.py b/app/chain/message.py index 5162a75d..8dd1f2f3 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -943,6 +943,16 @@ class MessageChain(ChainBase): return # 提取用户消息 + if not text.startswith("/ai"): + self.post_message(Notification( + channel=channel, + source=source, + userid=userid, + username=username, + title="消息格式错误,请以 /ai 开头" + )) + return + user_message = text[3:].strip() # 移除 "/ai" 前缀 if not user_message: self.post_message(Notification( From 64b93a009c28f91c0b61a62b21e1d8036a2f4ea6 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 23 Nov 2025 06:35:44 +0000 Subject: [PATCH 2/3] Refactor: Allow messages without /ai prefix Co-authored-by: jxxghp --- app/chain/message.py | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/app/chain/message.py b/app/chain/message.py index 8dd1f2f3..697151ed 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -943,17 +943,10 @@ class MessageChain(ChainBase): return # 提取用户消息 - if not text.startswith("/ai"): - self.post_message(Notification( - channel=channel, - source=source, - userid=userid, - username=username, - title="消息格式错误,请以 /ai 开头" - )) - return - - user_message = text[3:].strip() # 移除 "/ai" 前缀 + if text.startswith("/ai"): + user_message = text[3:].strip() # 移除 "/ai" 前缀 + else: + user_message = text.strip() # 按原消息处理 if not user_message: self.post_message(Notification( channel=channel, From 80396b4d3037343299855979be12890a9ed45a2c Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Sun, 23 Nov 2025 06:36:06 +0000 Subject: [PATCH 3/3] Fix: Make /ai command case-insensitive Co-authored-by: jxxghp --- app/chain/message.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/chain/message.py b/app/chain/message.py index 697151ed..b1e1912b 100644 --- a/app/chain/message.py +++ b/app/chain/message.py @@ -943,8 +943,8 @@ class MessageChain(ChainBase): return # 提取用户消息 - if text.startswith("/ai"): - user_message = text[3:].strip() # 移除 "/ai" 前缀 + if text.lower().startswith("/ai"): + user_message = text[3:].strip() # 移除 "/ai" 前缀(大小写不敏感) else: user_message = text.strip() # 按原消息处理 if not user_message: