mirror of
https://github.com/Nezumi-2711/astrbot_plugin_qq_group_daily_analysis.git
synced 2026-09-22 05:31:52 +00:00
feat(onebot): 正确识别 QQ 表情包 (subType=1) (#99 @nagatoquin33)
* feat(onebot): 正确识别 QQ 表情包 (subType=1) * refactor(onebot): 安全处理 sub_type 转换,只在有效时包含 sub_type 键
This commit is contained in:
@@ -257,10 +257,24 @@ class OneBotAdapter(PlatformAdapter):
|
||||
)
|
||||
|
||||
elif seg_type == "image":
|
||||
# QQ 平台: subType=1 表示表情包,通过 raw_data 传递给下游统计
|
||||
sub_type = seg_data.get("subType", seg_data.get("sub_type"))
|
||||
# 安全地转换为整数,防止非数字值导致异常
|
||||
try:
|
||||
is_sticker = int(sub_type) == 1
|
||||
except (TypeError, ValueError):
|
||||
is_sticker = False
|
||||
# 只在 sub_type 有效时包含在 raw_data 中
|
||||
raw_data: dict[str, Any] = {"summary": seg_data.get("summary", "")}
|
||||
if sub_type is not None:
|
||||
raw_data["sub_type"] = int(sub_type)
|
||||
contents.append(
|
||||
MessageContent(
|
||||
type=MessageContentType.IMAGE,
|
||||
type=MessageContentType.EMOJI
|
||||
if is_sticker
|
||||
else MessageContentType.IMAGE,
|
||||
url=seg_data.get("url", seg_data.get("file", "")),
|
||||
raw_data=raw_data,
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user