From 8e6dfe4f14bce98f8b582b99b0e2f02a15c21c84 Mon Sep 17 00:00:00 2001 From: FuQuan233 Date: Sat, 15 Feb 2025 16:35:02 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix=20string=20index=20out=20of?= =?UTF-8?q?=20range=20while=20sending=20messages?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- nonebot_plugin_llmchat/__init__.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nonebot_plugin_llmchat/__init__.py b/nonebot_plugin_llmchat/__init__.py index 9b332b5..4a691a7 100644 --- a/nonebot_plugin_llmchat/__init__.py +++ b/nonebot_plugin_llmchat/__init__.py @@ -252,6 +252,9 @@ async def process_messages(group_id: int): f"准备发送回复消息 群号:{group_id} 消息分段数:{len(reply.split(''))}" ) for r in reply.split(""): + # 似乎会有空消息的情况导致string index out of range异常 + if r.__len__() < 1: + continue # 删除前后多余的换行和空格 while r[0] == "\n" or r[0] == " ": r = r[1:]