diff --git a/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py b/astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py index a90ca7ebae..f5ab5ad883 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.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"