Skip to content

Commit 0c03177

Browse files
authored
fix: 修复 aiohttp 版本过新导致 qq-botpy 报错的问题 (#5316)
1 parent 20ff719 commit 0c03177

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

astrbot/core/platform/sources/qqofficial/qqofficial_message_event.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,25 @@
2525
from astrbot.core.utils.tencent_record_helper import wav_to_tencent_silk
2626

2727

28+
def _patch_qq_botpy_formdata() -> None:
29+
"""Patch qq-botpy for aiohttp>=3.12 compatibility.
30+
31+
qq-botpy 1.2.1 defines botpy.http._FormData._gen_form_data() and expects
32+
aiohttp.FormData to have a private flag named _is_processed, which is no
33+
longer present in newer aiohttp versions.
34+
"""
35+
36+
try:
37+
from botpy.http import _FormData # type: ignore
38+
39+
if not hasattr(_FormData, "_is_processed"):
40+
setattr(_FormData, "_is_processed", False)
41+
except Exception:
42+
logger.debug("[QQOfficial] Skip botpy FormData patch.")
43+
44+
45+
_patch_qq_botpy_formdata()
46+
2847
class QQOfficialMessageEvent(AstrMessageEvent):
2948
MARKDOWN_NOT_ALLOWED_ERROR = "不允许发送原生 markdown"
3049

0 commit comments

Comments
 (0)