diff --git a/astrbot/core/platform/astr_message_event.py b/astrbot/core/platform/astr_message_event.py index 4f3b88998..c82332770 100644 --- a/astrbot/core/platform/astr_message_event.py +++ b/astrbot/core/platform/astr_message_event.py @@ -269,10 +269,11 @@ class AstrMessageEvent(abc.ABC): match = re.search(pattern, buffer) if not match: break - matched_text = match.group() - await self.send(MessageChain([Plain(matched_text)])) + matched_text = match.group().strip() + if matched_text: + await self.send(MessageChain([Plain(matched_text)])) + await asyncio.sleep(1.5) # 限速 buffer = buffer[match.end() :] - await asyncio.sleep(1.5) # 限速 return buffer async def send_streaming( diff --git a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py index f41d39700..91a7444f3 100644 --- a/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py +++ b/astrbot/core/platform/sources/aiocqhttp/aiocqhttp_message_event.py @@ -228,7 +228,8 @@ class AiocqhttpMessageEvent(AstrMessageEvent): await self.send(MessageChain(chain=[comp])) await asyncio.sleep(1.5) # 限速 - if buffer.strip(): + buffer = buffer.strip() + if buffer: await self.send(MessageChain([Plain(buffer)])) return await super().send_streaming(generator, use_fallback)