支持adapter.discord的图片附件 (#673)

*  支持adapter.discord的图片附件

🎨 还原意外的更改

我的 isort 发力了

* ♻️ 改进写法

* 🐛 修复 Message data 传参错误

* 🐛 不支持直接传入 Attachment,转为 dict

🐛 其它类文件 `type='attachment'`
This commit is contained in:
Autuamn_End 2025-04-20 20:51:43 +08:00 committed by GitHub
parent fdbc3aa3be
commit c15f6f3f1c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -663,6 +663,25 @@ async def get_all_message(bot: Bot, ev: Event):
else:
logger.debug('[gsuid] 不支持该 Discord 事件...')
return
# 处理 Discord 消息中的附件
if ev.attachments:
from nonebot.adapters.discord.api import UNSET
from nonebot.adapters.discord.utils import model_dump
message.extend(
Message(
(
'image'
if (content_type := dc_attachment.content_type)
is not UNSET
and 'image' in content_type
else 'attachment'
),
model_dump(dc_attachment, exclude_unset=True),
)
for dc_attachment in ev.attachments
)
elif bot.adapter.get_name() == 'DoDo':
from nonebot.adapters.dodo import (
ChannelMessageEvent,