Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

![SpectreCore](https://avatars.githubusercontent.com/u/129108081?s=48&v=4)

[![version](https://img.shields.io/badge/version-v2.1.11-blue.svg?style=flat-square)](https://github.com/23q3/astrbot_plugin_SpectreCore)
[![version](https://img.shields.io/badge/version-v2.1.12-blue.svg?style=flat-square)](https://github.com/23q3/astrbot_plugin_SpectreCore)
[![license](https://img.shields.io/badge/license-AGPL--3.0-green.svg?style=flat-square)](LICENSE)
[![author](https://img.shields.io/badge/author-23q3-orange.svg?style=flat-square)](https://github.com/23q3)

Expand Down Expand Up @@ -70,9 +70,9 @@ SpectreCore (影芯) 是一个为 AstrBot 设计的高级群聊互动插件,

## 📋 最新版本

### v2.1.11 (2026-02-24)
### v2.1.12 (2026-06-01)

- 🐛 **修复机器人私聊消息存储路径错误** - 修复私聊中bot消息存入错误路径,导致用户看不到bot回复历史的问题 [#87](https://github.com/23q3/astrbot_plugin_SpectreCore/issues/87)[#90](https://github.com/23q3/astrbot_plugin_SpectreCore/pull/90) @Hola-Gracias
- 🐛 **修复图片遗漏** - call_llm()遗漏当前消息图片导致模型无法读取用户上传的图片 [#96](https://github.com/23q3/astrbot_plugin_SpectreCore/issues/96)

## ⚠️ 注意事项

Expand Down
1 change: 1 addition & 0 deletions changelogs/v2.1.12.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- 🐛 **修复图片遗漏** - call_llm()遗漏当前消息图片导致模型无法读取用户上传的图片 [#96](https://github.com/23q3/astrbot_plugin_SpectreCore/issues/96)
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"spectrecore",
"23q3",
"使大模型更好的主动回复群聊中的消息,带来生动和沉浸的群聊对话体验",
"2.1.11",
"2.1.12",
"https://github.com/23q3/astrbot_plugin_SpectreCore"
)
class SpectreCore(Star):
Expand Down
2 changes: 1 addition & 1 deletion metadata.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: spectrecore # 这是你的插件的唯一识别名。
desc: 使大模型更好的主动回复群聊中的消息,带来生动和沉浸的群聊对话体验 # 插件简短描述
help: 自动检测群聊消息并让AI模型进行回复,让群聊更加生动有趣。 # 插件的帮助信息
version: v2.1.11 # 插件版本号。格式:v1.1.1 或者 v1.1
version: v2.1.12 # 插件版本号。格式:v1.1.1 或者 v1.1
author: 23q3 # 作者
repo: https://github.com/23q3/astrbot_plugin_SpectreCore # 插件的仓库地址
display_name: 🌟 SpectreCore
54 changes: 34 additions & 20 deletions utils/llm_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,28 +241,42 @@ async def call_llm(event: AstrMessageEvent, config: AstrBotConfig, context: Cont

# 图片相关处理
image_urls = []
if image_count := config.get("image_processing", {}).get("image_count", 0):
if history_messages:
messages_to_show = history_messages[-history_limit:] if len(history_messages) > history_limit else history_messages

for message in reversed(messages_to_show):
if hasattr(message, "message") and message.message:
for component in message.message:
if isinstance(component, Image):
try:
url = component.file or component.url
if url:
image_urls.append(url)
if len(image_urls) >= image_count:
break
except Exception as e:
logger.warning(f"处理图片URL时出错: {e}")
continue
if len(image_urls) >= image_count:
break
# 首先收集当前消息链中的图片(用户刚发送的,不受 image_count 限制)
if hasattr(event, "message_obj") and hasattr(event.message_obj, "message"):
for component in event.message_obj.message:
if isinstance(component, Image):
try:
url = component.file or component.url
if url and url not in image_urls:
image_urls.append(url)
except Exception as e:
logger.warning(f"处理当前消息图片URL时出错: {e}")
continue

# 然后从历史消息中补充收集图片(受 image_count 限制)
history_image_count = config.get("image_processing", {}).get("image_count", 0)
if history_image_count and history_messages:
messages_to_show = history_messages[-history_limit:] if len(history_messages) > history_limit else history_messages

for message in reversed(messages_to_show):
if hasattr(message, "message") and message.message:
for component in message.message:
if isinstance(component, Image):
try:
url = component.file or component.url
if url and url not in image_urls:
image_urls.append(url)
if len(image_urls) >= history_image_count:
break
except Exception as e:
logger.warning(f"处理历史消息图片URL时出错: {e}")
continue
if len(image_urls) >= history_image_count:
break

if image_urls:
system_prompt += f"\n\n已经按照从晚到早的顺序为你提供了聊天记录中的{len(image_urls)}张图片,你可以直接查看并理解它们。这些图片出现在聊天记录中。"
if image_urls:
system_prompt += f"\n\n已经按照从晚到早的顺序为你提供了聊天记录中的{len(image_urls)}张图片,你可以直接查看并理解它们。这些图片出现在聊天记录中。"

# prompt 只保留用户当前消息,使用 MessageUtils 确保图片被转述
if hasattr(event, "message_obj") and hasattr(event.message_obj, "message"):
Expand Down
Loading