From 0c03177840a2ec50ebd803c01778fb92142a338d Mon Sep 17 00:00:00 2001 From: Lovely Moe Moli <44719954+moemoli@users.noreply.github.com> Date: Sun, 22 Feb 2026 16:45:28 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=20aiohttp=20=E7=89=88?= =?UTF-8?q?=E6=9C=AC=E8=BF=87=E6=96=B0=E5=AF=BC=E8=87=B4=20qq-botpy=20?= =?UTF-8?q?=E6=8A=A5=E9=94=99=E7=9A=84=E9=97=AE=E9=A2=98=20(#5316)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../qqofficial/qqofficial_message_event.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py b/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py index a90ca7eba..f5ab5ad88 100644 --- a/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py +++ b/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py @@ -25,6 +25,25 @@ from astrbot.core.utils.io import download_image_by_url, file_to_base64 from astrbot.core.utils.tencent_record_helper import wav_to_tencent_silk +def _patch_qq_botpy_formdata() -> None: + """Patch qq-botpy for aiohttp>=3.12 compatibility. + + qq-botpy 1.2.1 defines botpy.http._FormData._gen_form_data() and expects + aiohttp.FormData to have a private flag named _is_processed, which is no + longer present in newer aiohttp versions. + """ + + try: + from botpy.http import _FormData # type: ignore + + if not hasattr(_FormData, "_is_processed"): + setattr(_FormData, "_is_processed", False) + except Exception: + logger.debug("[QQOfficial] Skip botpy FormData patch.") + + +_patch_qq_botpy_formdata() + class QQOfficialMessageEvent(AstrMessageEvent): MARKDOWN_NOT_ALLOWED_ERROR = "不允许发送原生 markdown"