nonebot-plugin-aigf-master 1.3.0__tar.gz → 1.4.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/PKG-INFO +8 -6
  2. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/README.md +7 -5
  3. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/__init__.py +160 -1
  4. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/processor.py +10 -4
  5. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/prompt_builder.py +3 -0
  6. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master.egg-info/PKG-INFO +8 -6
  7. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/pyproject.toml +1 -1
  8. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/LICENSE +0 -0
  9. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/api_hooks.py +0 -0
  10. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/command_learner.py +0 -0
  11. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/config.py +0 -0
  12. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/context_bus.py +0 -0
  13. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/image_gen_client.py +0 -0
  14. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/image_handler.py +0 -0
  15. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/llm_client.py +0 -0
  16. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/meme_store.py +0 -0
  17. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/memory_store.py +0 -0
  18. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/models.py +0 -0
  19. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/peer_client.py +0 -0
  20. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/plugin_discovery.py +0 -0
  21. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/plugin_invoker.py +0 -0
  22. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/preset_store.py +0 -0
  23. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/response_parser.py +0 -0
  24. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/search_client.py +0 -0
  25. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master/vlm_client.py +0 -0
  26. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master.egg-info/SOURCES.txt +0 -0
  27. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master.egg-info/dependency_links.txt +0 -0
  28. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master.egg-info/requires.txt +0 -0
  29. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/nonebot_plugin_aigf_master.egg-info/top_level.txt +0 -0
  30. {nonebot_plugin_aigf_master-1.3.0 → nonebot_plugin_aigf_master-1.4.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-aigf-master
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: 群聊特化LLM聊天机器人(增强版),具有记忆、表情包、跨插件调用和跨bot通信能力
5
5
  License-Expression: MIT
6
6
  Requires-Python: <4.0,>=3.10
@@ -35,6 +35,7 @@ Dynamic: license-file
35
35
  ## 📖 介绍
36
36
 
37
37
  一个基于 NoneBot2 的群聊 AI 助手插件,能够自主收集和发送表情包、联网搜索知识、对群内信息进行记忆,还能够感知同实例内其它插件的输出、通过 LLM 调用其它插件、自主学习群内命令用法,并能通过子插件与其它 bot 通信获取消息和远程调用命令。
38
+ > 本项目有AI高度参与,若有做得不够好及需要改进的地方,欢迎在issue提出意见。
38
39
 
39
40
  ### 核心能力
40
41
 
@@ -45,6 +46,7 @@ Dynamic: license-file
45
46
  - 🖼️ **表情包功能**:AI 自主决定发表情包;自动从群聊中收藏
46
47
  - 🔍 **联网搜索**:支持 Tavily / Bocha / Bing,自动搜索不懂的梗和网络用语
47
48
  - 🧠 **四层记忆系统**:短期记忆、长期记忆、群友信息、文化记忆,LLM 自主管理
49
+ - 🎨 **AI 生图**:LLM可调用生图模型生成图片发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
48
50
 
49
51
  ### 基础能力
50
52
 
@@ -54,7 +56,6 @@ Dynamic: license-file
54
56
  - ⏱️ **不完整消息检测**:纯 @ 消息或连续发送时自动延长等待时间
55
57
  - 🕐 **消息时间标注**:可选为 LLM 看到的消息加上 `[MM-DD HH:MM]` 时间前缀(`AIGFM_SHOW_MESSAGE_TIME`)
56
58
  - 📄 **完整消息类型**:合并聊天记录、小程序/卡片、XML 消息均可解析与捕获
57
- - 🎨 **AI 生图**:LLM 生成图片自动发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
58
59
  - 🔒 **强制 JSON 输出**:确保 LLM 始终返回正确格式
59
60
  - ⚡ **轻量高效**:单次 LLM 调用完成对话 + 记忆管理 + 命令学习
60
61
 
@@ -109,19 +110,20 @@ AIGFM_VLM_ENABLED=true # 是否启用VLM(仅 vlm 模式有效
109
110
  AIGFM_VLM_MODEL="..." # VLM 模型名称(vlm 模式必填)
110
111
  AIGFM_VLM_BASE_URL="https://..." # VLM API 地址
111
112
  AIGFM_VLM_API_KEY="" # VLM API Key(为空时使用 chat 的 key)
113
+ ```
114
+
115
+ ### 可选
112
116
 
117
+ ```env
113
118
  # --- AI 生图 ---
114
119
  AIGFM_IMAGE_GEN_ENABLED=false # 是否启用 AI 生图(默认 false)
115
120
  AIGFM_IMAGE_GEN_MODEL="..." # 生图模型名称(豆包/Ark 示例: doubao-seedream-5-0-lite-260128)
116
121
  AIGFM_IMAGE_GEN_BASE_URL="https://..." # 生图 API 地址(OpenAI 兼容 images API;豆包示例 https://ark.cn-beijing.volces.com/api/v3)
117
122
  AIGFM_IMAGE_GEN_API_KEY="" # 生图 API Key(为空时使用 chat 的 key)
118
123
  AIGFM_IMAGE_GEN_MAX_SIZE="1024x1024" # 生成最大尺寸限制(宽x高,LLM 可指定比例/尺寸,程序自动缩放到不超过该上限)
124
+ AIGFM_IMAGE_GEN_MIN_SIZE="" # 生成最小尺寸(宽x高,为空不限制;用于满足服务最低像素要求,如豆包 Seedream 需 "1920x1920" 即 3686400 像素,非空时按比例放大到不小于该面积)
119
125
  AIGFM_IMAGE_GEN_WATERMARK=false # 生图水印(参考豆包类服务,仅参考图时传入,默认 false)
120
- ```
121
-
122
- ### 可选
123
126
 
124
- ```env
125
127
  # --- 基础 ---
126
128
  AIGFM_MEME_ENABLED=true # 是否启用表情包功能(默认 true)
127
129
  AIGFM_MEME_MAX_COUNT=200 # 自动收集的表情包最大数量(默认 200)
@@ -15,6 +15,7 @@
15
15
  ## 📖 介绍
16
16
 
17
17
  一个基于 NoneBot2 的群聊 AI 助手插件,能够自主收集和发送表情包、联网搜索知识、对群内信息进行记忆,还能够感知同实例内其它插件的输出、通过 LLM 调用其它插件、自主学习群内命令用法,并能通过子插件与其它 bot 通信获取消息和远程调用命令。
18
+ > 本项目有AI高度参与,若有做得不够好及需要改进的地方,欢迎在issue提出意见。
18
19
 
19
20
  ### 核心能力
20
21
 
@@ -25,6 +26,7 @@
25
26
  - 🖼️ **表情包功能**:AI 自主决定发表情包;自动从群聊中收藏
26
27
  - 🔍 **联网搜索**:支持 Tavily / Bocha / Bing,自动搜索不懂的梗和网络用语
27
28
  - 🧠 **四层记忆系统**:短期记忆、长期记忆、群友信息、文化记忆,LLM 自主管理
29
+ - 🎨 **AI 生图**:LLM可调用生图模型生成图片发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
28
30
 
29
31
  ### 基础能力
30
32
 
@@ -34,7 +36,6 @@
34
36
  - ⏱️ **不完整消息检测**:纯 @ 消息或连续发送时自动延长等待时间
35
37
  - 🕐 **消息时间标注**:可选为 LLM 看到的消息加上 `[MM-DD HH:MM]` 时间前缀(`AIGFM_SHOW_MESSAGE_TIME`)
36
38
  - 📄 **完整消息类型**:合并聊天记录、小程序/卡片、XML 消息均可解析与捕获
37
- - 🎨 **AI 生图**:LLM 生成图片自动发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
38
39
  - 🔒 **强制 JSON 输出**:确保 LLM 始终返回正确格式
39
40
  - ⚡ **轻量高效**:单次 LLM 调用完成对话 + 记忆管理 + 命令学习
40
41
 
@@ -89,19 +90,20 @@ AIGFM_VLM_ENABLED=true # 是否启用VLM(仅 vlm 模式有效
89
90
  AIGFM_VLM_MODEL="..." # VLM 模型名称(vlm 模式必填)
90
91
  AIGFM_VLM_BASE_URL="https://..." # VLM API 地址
91
92
  AIGFM_VLM_API_KEY="" # VLM API Key(为空时使用 chat 的 key)
93
+ ```
94
+
95
+ ### 可选
92
96
 
97
+ ```env
93
98
  # --- AI 生图 ---
94
99
  AIGFM_IMAGE_GEN_ENABLED=false # 是否启用 AI 生图(默认 false)
95
100
  AIGFM_IMAGE_GEN_MODEL="..." # 生图模型名称(豆包/Ark 示例: doubao-seedream-5-0-lite-260128)
96
101
  AIGFM_IMAGE_GEN_BASE_URL="https://..." # 生图 API 地址(OpenAI 兼容 images API;豆包示例 https://ark.cn-beijing.volces.com/api/v3)
97
102
  AIGFM_IMAGE_GEN_API_KEY="" # 生图 API Key(为空时使用 chat 的 key)
98
103
  AIGFM_IMAGE_GEN_MAX_SIZE="1024x1024" # 生成最大尺寸限制(宽x高,LLM 可指定比例/尺寸,程序自动缩放到不超过该上限)
104
+ AIGFM_IMAGE_GEN_MIN_SIZE="" # 生成最小尺寸(宽x高,为空不限制;用于满足服务最低像素要求,如豆包 Seedream 需 "1920x1920" 即 3686400 像素,非空时按比例放大到不小于该面积)
99
105
  AIGFM_IMAGE_GEN_WATERMARK=false # 生图水印(参考豆包类服务,仅参考图时传入,默认 false)
100
- ```
101
-
102
- ### 可选
103
106
 
104
- ```env
105
107
  # --- 基础 ---
106
108
  AIGFM_MEME_ENABLED=true # 是否启用表情包功能(默认 true)
107
109
  AIGFM_MEME_MAX_COUNT=200 # 自动收集的表情包最大数量(默认 200)
@@ -8,10 +8,12 @@ from datetime import datetime
8
8
 
9
9
  import anyio
10
10
  import httpx
11
- from nonebot import get_driver, logger, on_command, on_message, require
11
+ from nonebot import get_driver, logger, on_command, on_message, on_notice, require
12
12
  from nonebot.adapters import Event, Message
13
13
  from nonebot.adapters.onebot.v11 import (
14
14
  Bot, GroupMessageEvent, MessageSegment, Message as OneBotMessage,
15
+ GroupBanNoticeEvent, GroupDecreaseNoticeEvent, GroupIncreaseNoticeEvent,
16
+ GroupRecallNoticeEvent, PokeNotifyEvent,
15
17
  )
16
18
  from nonebot.params import CommandArg
17
19
  from nonebot.permission import SUPERUSER
@@ -216,6 +218,76 @@ async def _parse_message(bot: Bot, event: GroupMessageEvent, message: Message, b
216
218
  elif seg.type == "xml":
217
219
  has_non_at = True
218
220
  content += "[收到一条XML消息] "
221
+ elif seg.type == "face":
222
+ # 部分客户端会带表情名(text),缺失时用 id 兜底
223
+ has_non_at = True
224
+ face_name = seg.data.get("text") or seg.data.get("id")
225
+ content += f"[QQ表情 {face_name}] " if face_name else "[QQ表情] "
226
+ elif seg.type == "record":
227
+ has_non_at = True
228
+ content += "[收到一条语音消息] "
229
+ elif seg.type == "video":
230
+ has_non_at = True
231
+ content += "[收到一条视频消息] "
232
+ elif seg.type == "file":
233
+ has_non_at = True
234
+ # go-cqhttp/NapCat 字段名略有差异:file_name/name、file_size/size
235
+ file_name = seg.data.get("file_name") or seg.data.get("name")
236
+ file_size = seg.data.get("file_size") or seg.data.get("size")
237
+ size_str = ""
238
+ if file_size:
239
+ try:
240
+ size_bytes = int(file_size)
241
+ if size_bytes >= 1024 * 1024:
242
+ size_str = f"({size_bytes / 1024 / 1024:.1f}MB)"
243
+ elif size_bytes >= 1024:
244
+ size_str = f"({size_bytes / 1024:.1f}KB)"
245
+ else:
246
+ size_str = f"({size_bytes}B)"
247
+ except (TypeError, ValueError):
248
+ pass
249
+ content += f"[群文件: {file_name}{size_str}] " if file_name else "[群文件] "
250
+ elif seg.type == "share":
251
+ has_non_at = True
252
+ share_title = seg.data.get("title", "")
253
+ share_url = seg.data.get("url", "")
254
+ share_content = seg.data.get("content")
255
+ parts = []
256
+ if share_title:
257
+ parts.append(share_title)
258
+ if share_url:
259
+ parts.append(share_url)
260
+ if share_content:
261
+ parts.append(share_content)
262
+ content += f"[分享链接: {' | '.join(parts)}] " if parts else "[分享链接] "
263
+ elif seg.type == "contact":
264
+ has_non_at = True
265
+ contact_type = "群" if seg.data.get("type") == "group" else "好友"
266
+ contact_id = seg.data.get("id", "")
267
+ content += f"[推荐{contact_type}: {contact_id}] " if contact_id else f"[推荐{contact_type}] "
268
+ elif seg.type == "location":
269
+ has_non_at = True
270
+ loc_title = seg.data.get("title", "")
271
+ lat, lon = seg.data.get("lat", ""), seg.data.get("lon", "")
272
+ parts = [loc_title] if loc_title else []
273
+ if lat and lon:
274
+ parts.append(f"{lat},{lon}")
275
+ if seg.data.get("content"):
276
+ parts.append(seg.data["content"])
277
+ content += f"[位置: {' | '.join(parts)}] " if parts else "[位置] "
278
+ elif seg.type == "music":
279
+ has_non_at = True
280
+ music_title = seg.data.get("title")
281
+ music_id = seg.data.get("id")
282
+ content += f"[音乐分享: {music_title}] " if music_title else f"[音乐分享 {music_id}] "
283
+ elif seg.type == "dice":
284
+ has_non_at = True
285
+ dice_result = seg.data.get("result")
286
+ content += f"[骰子 {dice_result}] " if dice_result else "[骰子] "
287
+ elif seg.type in ("rps", "shake", "anonymous", "node"):
288
+ has_non_at = True
289
+ label = {"rps": "猜拳", "shake": "窗口抖动", "anonymous": "匿名消息", "node": "合并聊天记录节点"}[seg.type]
290
+ content += f"[{label}] "
219
291
 
220
292
  return content.strip(), not has_non_at
221
293
 
@@ -316,6 +388,22 @@ def _add_peer_message(group_id: int, source: str, content: str, reset_timer: boo
316
388
  _group_last_time[group_id] = asyncio.get_event_loop().time()
317
389
 
318
390
 
391
+ def _add_notice_message(group_id: int, content: str):
392
+ """将群系统通知(戳一戳/禁言/进出群/消息撤回)加入消息缓冲区
393
+
394
+ user_id 留空 → 渲染为 `[系统]: '内容'`,LLM 可区分系统通知与群友发言
395
+ """
396
+ if group_id not in _group_chunks:
397
+ _group_chunks[group_id] = []
398
+ _group_chunks[group_id].append(ChatMessage(
399
+ time=datetime.now(),
400
+ user_name="系统",
401
+ content=content,
402
+ user_id="",
403
+ ))
404
+ _group_last_time[group_id] = asyncio.get_event_loop().time()
405
+
406
+
319
407
  async def _describe_peer_image(group_id: int, source: str, image_url: str = "", image_base64: str = ""):
320
408
  """在 Bot A 侧对其它 bot 推送的图片做 VLM 描述后加入消息缓冲区"""
321
409
  _on_image_start(group_id)
@@ -460,6 +548,55 @@ def _is_group_msg(event: Event) -> bool:
460
548
  return isinstance(event, GroupMessageEvent)
461
549
 
462
550
 
551
+ _NOTICE_TYPES = (
552
+ PokeNotifyEvent, GroupBanNoticeEvent, GroupIncreaseNoticeEvent,
553
+ GroupDecreaseNoticeEvent, GroupRecallNoticeEvent,
554
+ )
555
+
556
+
557
+ def _is_group_notice(event: Event) -> bool:
558
+ """只收群内系统通知;PokeNotifyEvent 的 group_id 可能为空(私聊戳一戳),过滤掉"""
559
+ if not isinstance(event, _NOTICE_TYPES):
560
+ return False
561
+ return bool(getattr(event, "group_id", None))
562
+
563
+
564
+ async def _resolve_notice_text(bot: Bot, event: Event) -> str | None:
565
+ """把群 notice 事件渲染成一行文本;昵称查询失败回落 QQ 号"""
566
+ group_id = int(getattr(event, "group_id"))
567
+
568
+ async def _name(user_id: int) -> str:
569
+ try:
570
+ info = await bot.get_group_member_info(group_id=group_id, user_id=user_id)
571
+ return info.get("nickname") or str(user_id)
572
+ except Exception:
573
+ return str(user_id)
574
+
575
+ if isinstance(event, PokeNotifyEvent):
576
+ return f"{await _name(event.user_id)} 戳了戳 {await _name(event.target_id)}"
577
+ if isinstance(event, GroupBanNoticeEvent):
578
+ if event.sub_type == "self_ban":
579
+ return f"我被禁言 {event.duration} 分钟"
580
+ if event.sub_type == "self_lift_ban":
581
+ return "我被解除禁言"
582
+ if event.sub_type == "lift_ban":
583
+ return f"{await _name(event.operator_id)} 解除了 {await _name(event.user_id)} 的禁言"
584
+ return f"{await _name(event.operator_id)} 将 {await _name(event.user_id)} 禁言 {event.duration} 分钟"
585
+ if isinstance(event, GroupIncreaseNoticeEvent):
586
+ return f"{await _name(event.user_id)} 加入了群聊"
587
+ if isinstance(event, GroupDecreaseNoticeEvent):
588
+ if event.sub_type == "kick_me":
589
+ return "我被移出了群聊"
590
+ if event.sub_type == "kick":
591
+ return f"{await _name(event.user_id)} 被 {await _name(event.operator_id)} 移出了群聊"
592
+ return f"{await _name(event.user_id)} 退出了群聊"
593
+ if isinstance(event, GroupRecallNoticeEvent):
594
+ if event.user_id == event.operator_id:
595
+ return f"{await _name(event.user_id)} 撤回了一条消息"
596
+ return f"{await _name(event.operator_id)} 撤回了 {await _name(event.user_id)} 的一条消息"
597
+ return None
598
+
599
+
463
600
  # 这里新增/改名的管理命令必须同步 processor.SELF_COMMANDS:
464
601
  # synthetic 事件携带真实触发用户的 user_id,少了同步会让 LLM 有机会代为执行这些命令
465
602
  status_cmd = on_command(rule=_is_group_msg, permission=SUPERUSER,
@@ -475,6 +612,7 @@ set_preset_cmd = on_command(rule=_is_group_msg, permission=SUPERUSER,
475
612
  reload_meme_cmd = on_command(rule=_is_group_msg, permission=SUPERUSER,
476
613
  cmd="reload_meme", aliases={"重载表情包"}, priority=0, block=True)
477
614
  auto_chat = on_message(rule=_is_group_msg, priority=1, block=False)
615
+ group_notice = on_notice(rule=_is_group_notice, priority=1, block=False)
478
616
 
479
617
 
480
618
  @status_cmd.handle()
@@ -604,6 +742,27 @@ async def handle_auto_chat(bot: Bot, event: GroupMessageEvent):
604
742
  pass
605
743
 
606
744
 
745
+ @group_notice.handle()
746
+ async def handle_group_notice(bot: Bot, event: Event):
747
+ """群系统通知(戳一戳/禁言/进出群/消息撤回)→ 渲染后入缓冲区
748
+
749
+ notice 事件没有用户消息上下文:不更新 processor._current_user_id(避免污染工具调用身份),
750
+ 批处理触发依赖该群最近一次真实用户消息(与 peer 推送的等待行为一致)
751
+ """
752
+ group_id = int(getattr(event, "group_id"))
753
+ if group_id not in plugin_config.aigfm_enabled_groups:
754
+ return
755
+ try:
756
+ text = await _resolve_notice_text(bot, event)
757
+ except Exception as e:
758
+ logger.error(f"[通知] 事件渲染失败: {e}")
759
+ return
760
+ if not text:
761
+ return
762
+ logger.info(f"[通知] 群{group_id}: {text}")
763
+ _add_notice_message(group_id, text)
764
+
765
+
607
766
  # ========== 启动 ==========
608
767
 
609
768
  @get_driver().on_startup
@@ -290,7 +290,7 @@ class MessageProcessor:
290
290
 
291
291
  used_tool = False
292
292
  if (self.config.aigfm_search_enabled and self.search):
293
- response_str, used_tool = await self._call_llm_with_tools(prompt, sticker_images)
293
+ response_str, used_tool = await self._call_llm_with_tools(prompt, sticker_images, plugin_commands, peer_commands)
294
294
  else:
295
295
  response_str = await self.llm.chat(
296
296
  prompt, self.config.aigfm_llm_model,
@@ -370,7 +370,13 @@ class MessageProcessor:
370
370
 
371
371
  return reply_segments
372
372
 
373
- async def _call_llm_with_tools(self, prompt: str, sticker_images: list[str]) -> tuple[str | None, bool]:
373
+ async def _call_llm_with_tools(self, prompt: str, sticker_images: list[str],
374
+ plugin_commands: list | None = None,
375
+ peer_commands: list | None = None) -> tuple[str | None, bool]:
376
+ # 命令清单为空时不注入命令调用工具:模型看不到工具就不会填「无/none」占位值,
377
+ # 命令学习走 JSON 输出字段,不受影响;学到第一条命令后清单非空,工具自动出现
378
+ plugin_commands = plugin_commands or []
379
+ peer_commands = peer_commands or []
374
380
  tools = []
375
381
  if self.config.aigfm_search_enabled:
376
382
  tools.append({
@@ -380,7 +386,7 @@ class MessageProcessor:
380
386
  "parameters": {"type": "object", "properties": {"query": {"type": "string"}}, "required": ["query"]},
381
387
  },
382
388
  })
383
- if self.config.aigfm_invoke_enabled:
389
+ if self.config.aigfm_invoke_enabled and plugin_commands:
384
390
  tools.append({
385
391
  "type": "function", "function": {
386
392
  "name": "invoke_plugin",
@@ -392,7 +398,7 @@ class MessageProcessor:
392
398
  }, "required": ["command"]},
393
399
  },
394
400
  })
395
- if self.config.aigfm_invoke_enabled and self.peer_client:
401
+ if self.config.aigfm_invoke_enabled and self.peer_client and peer_commands:
396
402
  peer_names = "、".join(self.peer_client.names())
397
403
  tools.append({
398
404
  "type": "function", "function": {
@@ -412,6 +412,9 @@ index 对应上面数组的下标(从 0 开始)。
412
412
  - 不要对图片内容发表评论,除非群友@了你
413
413
  - 合并聊天记录([收到一条合并聊天记录])→ 不回复,通常不是发给你的
414
414
  - 小程序/卡片链接([小程序/卡片: ...])→ 不回复,通常不是发给你的
415
+ - 语音/视频/文件(内容不可见)→ 不主动回复,确需回应时简短说明「听不到/看不到内容」
416
+ - QQ表情/链接分享/位置/音乐(内容可识别)→ 通常不是发给你的,视情况正常应对
417
+ - `[系统]` 开头的通知(戳一戳/禁言/进出群/消息撤回)→ 一般静默不回复;新人进群可以发欢迎词;被 @ 或话题与你相关才回应;被戳时可以根据你的社交能量适当回应
415
418
 
416
419
  ## 其他规则
417
420
  - 不要编造表情包 id,只能使用上面列出的
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: nonebot-plugin-aigf-master
3
- Version: 1.3.0
3
+ Version: 1.4.0
4
4
  Summary: 群聊特化LLM聊天机器人(增强版),具有记忆、表情包、跨插件调用和跨bot通信能力
5
5
  License-Expression: MIT
6
6
  Requires-Python: <4.0,>=3.10
@@ -35,6 +35,7 @@ Dynamic: license-file
35
35
  ## 📖 介绍
36
36
 
37
37
  一个基于 NoneBot2 的群聊 AI 助手插件,能够自主收集和发送表情包、联网搜索知识、对群内信息进行记忆,还能够感知同实例内其它插件的输出、通过 LLM 调用其它插件、自主学习群内命令用法,并能通过子插件与其它 bot 通信获取消息和远程调用命令。
38
+ > 本项目有AI高度参与,若有做得不够好及需要改进的地方,欢迎在issue提出意见。
38
39
 
39
40
  ### 核心能力
40
41
 
@@ -45,6 +46,7 @@ Dynamic: license-file
45
46
  - 🖼️ **表情包功能**:AI 自主决定发表情包;自动从群聊中收藏
46
47
  - 🔍 **联网搜索**:支持 Tavily / Bocha / Bing,自动搜索不懂的梗和网络用语
47
48
  - 🧠 **四层记忆系统**:短期记忆、长期记忆、群友信息、文化记忆,LLM 自主管理
49
+ - 🎨 **AI 生图**:LLM可调用生图模型生成图片发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
48
50
 
49
51
  ### 基础能力
50
52
 
@@ -54,7 +56,6 @@ Dynamic: license-file
54
56
  - ⏱️ **不完整消息检测**:纯 @ 消息或连续发送时自动延长等待时间
55
57
  - 🕐 **消息时间标注**:可选为 LLM 看到的消息加上 `[MM-DD HH:MM]` 时间前缀(`AIGFM_SHOW_MESSAGE_TIME`)
56
58
  - 📄 **完整消息类型**:合并聊天记录、小程序/卡片、XML 消息均可解析与捕获
57
- - 🎨 **AI 生图**:LLM 生成图片自动发到群里,尺寸由 LLM 决定(程序限最大尺寸),支持参考图改绘(回复图片消息或从聊天记录选图)
58
59
  - 🔒 **强制 JSON 输出**:确保 LLM 始终返回正确格式
59
60
  - ⚡ **轻量高效**:单次 LLM 调用完成对话 + 记忆管理 + 命令学习
60
61
 
@@ -109,19 +110,20 @@ AIGFM_VLM_ENABLED=true # 是否启用VLM(仅 vlm 模式有效
109
110
  AIGFM_VLM_MODEL="..." # VLM 模型名称(vlm 模式必填)
110
111
  AIGFM_VLM_BASE_URL="https://..." # VLM API 地址
111
112
  AIGFM_VLM_API_KEY="" # VLM API Key(为空时使用 chat 的 key)
113
+ ```
114
+
115
+ ### 可选
112
116
 
117
+ ```env
113
118
  # --- AI 生图 ---
114
119
  AIGFM_IMAGE_GEN_ENABLED=false # 是否启用 AI 生图(默认 false)
115
120
  AIGFM_IMAGE_GEN_MODEL="..." # 生图模型名称(豆包/Ark 示例: doubao-seedream-5-0-lite-260128)
116
121
  AIGFM_IMAGE_GEN_BASE_URL="https://..." # 生图 API 地址(OpenAI 兼容 images API;豆包示例 https://ark.cn-beijing.volces.com/api/v3)
117
122
  AIGFM_IMAGE_GEN_API_KEY="" # 生图 API Key(为空时使用 chat 的 key)
118
123
  AIGFM_IMAGE_GEN_MAX_SIZE="1024x1024" # 生成最大尺寸限制(宽x高,LLM 可指定比例/尺寸,程序自动缩放到不超过该上限)
124
+ AIGFM_IMAGE_GEN_MIN_SIZE="" # 生成最小尺寸(宽x高,为空不限制;用于满足服务最低像素要求,如豆包 Seedream 需 "1920x1920" 即 3686400 像素,非空时按比例放大到不小于该面积)
119
125
  AIGFM_IMAGE_GEN_WATERMARK=false # 生图水印(参考豆包类服务,仅参考图时传入,默认 false)
120
- ```
121
-
122
- ### 可选
123
126
 
124
- ```env
125
127
  # --- 基础 ---
126
128
  AIGFM_MEME_ENABLED=true # 是否启用表情包功能(默认 true)
127
129
  AIGFM_MEME_MAX_COUNT=200 # 自动收集的表情包最大数量(默认 200)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "nonebot-plugin-aigf-master"
7
- version = "1.3.0"
7
+ version = "1.4.0"
8
8
  description = "群聊特化LLM聊天机器人(增强版),具有记忆、表情包、跨插件调用和跨bot通信能力"
9
9
  readme = "README.md"
10
10
  license = "MIT"