From 706cc516580dc3eeb7d72e4a39a65b3890ddd4d7 Mon Sep 17 00:00:00 2001 From: Zelly <43312573+liu2-3zhi@users.noreply.github.com> Date: Wed, 14 Feb 2024 11:37:42 +0800 Subject: [PATCH] Update http_service.py --- platforms/http_service.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/platforms/http_service.py b/platforms/http_service.py index ea0e041b..7827debd 100644 --- a/platforms/http_service.py +++ b/platforms/http_service.py @@ -13,6 +13,8 @@ from constants import config, BotPlatform from universal import handle_message +from urllib.parse import unquote + app = Quart(__name__) lock = threading.Lock() @@ -140,7 +142,7 @@ async def v2_chat(): async def v2_chat_response(): """异步请求时,配合/v2/chat获取内容""" request_id = request.args.get("request_id") - request_id = re.sub(r'^["\'%22]|["\'%22]$', '', request_id) # 添加替换操作,以兼容带有引号的request_id。 + request_id = re.sub(r'^[%22%27"\'"]*|[%22%27"\'"]*$', '', request_id) # 添加替换操作,以兼容头部和尾部带有引号和URL编码引号的request_id。 bot_request: BotRequest = request_dic.get(request_id, None) if bot_request is None: return ResponseResult(message="没有更多了!", result_status=RESPONSE_FAILED).to_json() @@ -152,8 +154,6 @@ async def v2_chat_response(): logger.debug(f"Bot request {request_id} response -> \n{response[:100]}") return response - - def clear_request_dict(): logger.debug("Watch and clean request_dic.") while True: