mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-08 04:55:51 +08:00
✨ 支持adapter.discord的图片附件 (#673)
* ✨ 支持adapter.discord的图片附件 🎨 还原意外的更改 我的 isort 发力了 * ♻️ 改进写法 * 🐛 修复 Message data 传参错误 * 🐛 不支持直接传入 Attachment,转为 dict 🐛 其它类文件 `type='attachment'`
This commit is contained in:
parent
fdbc3aa3be
commit
c15f6f3f1c
@ -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,
|
||||
|
Loading…
x
Reference in New Issue
Block a user