Commit 76f24fd

benny-dou <60535774+benny-dou@users.noreply.github.com>
2026-06-04 02:53:11
chore(ai): separate AI permissions
1 parent 9f8ab49
Changed files (3)
src/messages/help.py
@@ -38,11 +38,16 @@ def social_media_help(message:Message):
         msg += "\n🔴油管"
         msg += "\n🅱️哔哩哔哩"
         msg += "\n🆕和所有yt-dlp支持的链接\n"
-    if permission["ai"]:
+    if permission["ai_text"]:
         msg += f"\n🤖**AI对话**: 发送 `{PREFIX.AI_TEXT_GENERATION}` 查看详细教程"
+    if permission["ai_img"]:
         msg += f"\n🌠**AI生图**: 发送 `{PREFIX.AI_IMG_GENERATION}` 查看详细教程"
+    if permission["ai_video"]:
         msg += f"\n📽**AI视频**: 发送 `{PREFIX.AI_VIDEO_GENERATION}` 查看详细教程"
+    if permission["ai_summarize"]:
         msg += f"\n📖**AI总结**: 发送 `{PREFIX.AI_SUMMARY}` 查看详细教程"
+    if permission["chat_summary"]:
+        msg += f"\n📖**总结聊天记录**: 发送 `{PREFIX.CHAT_SUMMARY}` 查看详细教程"
     if permission["asr"]:
         msg += f"\n🗣**语音转文字**: `{PREFIX.ASR}` + 语音消息"
     if permission["tts"]:
@@ -57,7 +62,6 @@ def social_media_help(message:Message):
         msg += f"\n📃**提取字幕**: `{PREFIX.SUBTITLE}` + B站或油管链接"
     if permission["history"]:
         msg += f"\n🗣**查询聊天记录**: 发送 `{PREFIX.HISTORY}` 查看详细教程"
-        msg += f"\n📖**总结聊天记录**: 发送 `{PREFIX.CHAT_SUMMARY}` 查看详细教程"
     if permission["wget"]:
         msg += f"\n⏬**下载文件**: `{PREFIX.WGET}` + URL"
     if permission["tmdb"]:
src/messages/main.py
@@ -61,7 +61,11 @@ async def process_message(
     target_chat: int | str | None = None,
     reply_msg_id: int = 0,
     *,
-    ai: bool = True,  # GPT Chat
+    ai_text: bool = True,  # Text Generation
+    ai_img: bool = True,  # AI Image Generation
+    ai_video: bool = True,  # AI Video Generation
+    ai_summarize: bool = True,  # GPT Summary
+    chat_summary: bool = True,  # AI Chat Summary.
     asr: bool = True,  # Voice to Text
     audio_extract: bool = True,  # Extract Audio from message. /audio -> m4a file. /voice -> wav file
     danmu: bool = True,  # Query Danmu database.
@@ -71,7 +75,6 @@ async def process_message(
     history: bool = True,  # Query Chat History.
     price: bool = True,  # Query Stock / Fiat / Crypto price.
     subtitle: bool = True,  # Download YouTube subtitle.
-    summary: bool = True,  # AI Chat Summary.
     tts: bool = True,  # Text to Speech.
     quotly: bool = True,  # Quote message.
     convert_chinese: bool = True,  # Traditional Chinese <-> Simplified Chinese.
@@ -101,11 +104,16 @@ async def process_message(
         kwargs["target_chat"] = to_int(kwargs["target_chat"])
     message, msg_kwargs = parse_kwargs(message)
     kwargs |= msg_kwargs  # merge the kwargs from the message text
-    if ai:
+    if ai_text:
         await ai_text_generation(client, message, **kwargs)  # /ai
+    if ai_img:
         await ai_image_generation(client, message, **kwargs)  # /gen
+    if ai_video:
         await ai_video_generation(client, message, **kwargs)  # /gvid
+    if ai_summarize:
         await ai_summary(client, message, **kwargs)  # /summary
+    if chat_summary:
+        await ai_chat_summary(client, message, **kwargs)  # /chatsum
     if asr:
         await voice_to_text(client, message, **kwargs)  # /asr
     if audio_extract:
@@ -124,8 +132,6 @@ async def process_message(
         await get_asset_price(client, message, **kwargs)  # /price
     if history:
         await query_chat_history(client, message, **kwargs)  # /history
-    if summary:
-        await ai_chat_summary(client, message, **kwargs)  # /chatsum
     if danmu:
         await query_danmu(client, message, **kwargs)  # /danmu
     if favorite:
src/permission.py
@@ -46,7 +46,11 @@ def set_permission(message: Message) -> dict:
         "disabled": False,  # this is the switch for all permissions
         "prepend_sender_user": False,  # prepend: 👤[@username](tg://user?id={uid})//
         "need_prefix": True,  # need /dl for social media preview
-        "ai": True,
+        "ai_text": True,
+        "ai_img": True,
+        "ai_video": True,
+        "ai_summarize": True,
+        "chat_summary": True,
         "asr": True,
         "audio_extract": True,
         "danmu": True,
@@ -88,8 +92,6 @@ def set_permission(message: Message) -> dict:
     # skip for service message
     if message.service:
         permissions["disabled"] = True
-    if ctype == "PRIVATE":
-        permissions["need_prefix"] = False
 
     # Set permissions via environment variables
     permissions |= global_permissions()  # CONFIG_GLOBAL