Skip to content

Commit 25f7a68

Browse files
authored
Merge pull request #1709 from shuiping233/fix-qq-offical-session-bug
fix: qq_official适配器使用SessionController(会话控制)功能时机器人回复消息无法发送到聊天平台
2 parents 1f5a7e7 + 62d8cf7 commit 25f7a68

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

astrbot/core/pipeline/respond/stage.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -128,9 +128,7 @@ async def process(
128128
"streaming_segmented", False
129129
)
130130
logger.info(f"应用流式输出({event.get_platform_name()})")
131-
await event._pre_send()
132131
await event.send_streaming(result.async_stream, use_fallback)
133-
await event._post_send()
134132
return
135133
elif len(result.chain) > 0:
136134
# 检查路径映射
@@ -141,8 +139,6 @@ async def process(
141139
component.file = path_Mapping(mappings, component.file)
142140
event.get_result().chain[idx] = component
143141

144-
await event._pre_send()
145-
146142
# 检查消息链是否为空
147143
try:
148144
if await self._is_empty_message_chain(result.chain):
@@ -158,9 +154,14 @@ async def process(
158154
c for c in result.chain if not isinstance(c, Comp.Record)
159155
]
160156

161-
if self.enable_seg and (
162-
(self.only_llm_result and result.is_llm_result())
163-
or not self.only_llm_result
157+
if (
158+
self.enable_seg
159+
and (
160+
(self.only_llm_result and result.is_llm_result())
161+
or not self.only_llm_result
162+
)
163+
and event.get_platform_name()
164+
not in ["qq_official", "weixin_official_account", "dingtalk"]
164165
):
165166
decorated_comps = []
166167
if self.reply_with_mention:
@@ -208,7 +209,6 @@ async def process(
208209
logger.error(traceback.format_exc())
209210
logger.error(f"发送消息失败: {e} chain: {result.chain}")
210211

211-
await event._post_send()
212212
logger.info(
213213
f"AstrBot -> {event.get_sender_name()}/{event.get_sender_id()}: {event._outline_chain(result.chain)}"
214214
)

astrbot/core/pipeline/result_decorate/stage.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,11 @@ async def process(
141141
break
142142

143143
# 分段回复
144-
if self.enable_segmented_reply:
144+
if self.enable_segmented_reply and event.get_platform_name() not in [
145+
"qq_official",
146+
"weixin_official_account",
147+
"dingtalk",
148+
]:
145149
if (
146150
self.only_llm_result and result.is_llm_result()
147151
) or not self.only_llm_result:

astrbot/core/pipeline/waking_check/stage.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,6 @@ async def process(
135135
f"插件 {star_map[handler.handler_module_path].name}: {e}"
136136
)
137137
)
138-
await event._post_send()
139138
event.stop_event()
140139
passed = False
141140
break
@@ -150,7 +149,6 @@ async def process(
150149
f"您(ID: {event.get_sender_id()})的权限不足以使用此指令。通过 /sid 获取 ID 并请管理员添加。"
151150
)
152151
)
153-
await event._post_send()
154152
logger.info(
155153
f"触发 {star_map[handler.handler_module_path].name} 时, 用户(ID={event.get_sender_id()}) 权限不足。"
156154
)

astrbot/core/platform/astr_message_event.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -235,10 +235,10 @@ async def send_streaming(
235235
self._has_send_oper = True
236236

237237
async def _pre_send(self):
238-
"""调度器会在执行 send() 前调用该方法"""
238+
"""调度器会在执行 send() 前调用该方法 deprecated in v3.5.18"""
239239

240240
async def _post_send(self):
241-
"""调度器会在执行 send() 后调用该方法"""
241+
"""调度器会在执行 send() 后调用该方法 deprecated in v3.5.18"""
242242

243243
def set_result(self, result: Union[MessageEventResult, str]):
244244
"""设置消息事件的结果。

astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ def __init__(
2828
self.send_buffer = None
2929

3030
async def send(self, message: MessageChain):
31-
if not self.send_buffer:
32-
self.send_buffer = message
33-
else:
34-
self.send_buffer.chain.extend(message.chain)
31+
self.send_buffer = message
32+
await self._post_send()
3533

3634
async def send_streaming(self, generator, use_fallback: bool = False):
3735
"""流式输出仅支持消息列表私聊"""

0 commit comments

Comments
 (0)