From a21c25c20e7c262dfe5a6e5203e8ddcaf2857287 Mon Sep 17 00:00:00 2001 From: KimigaiiWuyi <444835641@qq.com> Date: Wed, 15 Nov 2023 23:54:26 +0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20=E4=BF=AE=E5=A4=8D=E5=92=8C?= =?UTF-8?q?=E5=AE=8C=E5=96=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- GenshinUID/client.py | 22 +++++++++++++++------- pyproject.toml | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/GenshinUID/client.py b/GenshinUID/client.py index 3cb4e9a8..b79f6f40 100644 --- a/GenshinUID/client.py +++ b/GenshinUID/client.py @@ -625,11 +625,14 @@ async def guild_send( msg_id: Optional[str], guild_id: Optional[str], ): - from nonebot.adapters.qq.exception import ActionFailed from nonebot.adapters.qq.bot import Bot as qqbot + from nonebot.adapters.qq.exception import ActionFailed assert isinstance(bot, qqbot) + if target_id is None: + return + async def _send(content: Optional[str], image: Optional[str]): result: Dict[str, Any] = {'msg_id': msg_id} if image: @@ -650,7 +653,7 @@ async def guild_send( if target_type == 'group': await bot.post_messages( - channel_id=str(target_id) if target_id else 0, + channel_id=str(target_id), **result, ) else: @@ -664,10 +667,11 @@ async def guild_send( recipient_id=str(target_id), source_guild_id=str(guild_id), ) - await bot.post_dms_messages( - guild_id=dms.guild_id, - **result, - ) + if dms.guild_id: + await bot.post_dms_messages( + guild_id=dms.guild_id, + **result, + ) if node: for _msg in node: @@ -824,7 +828,11 @@ async def group_send( async def _send(content: Optional[str], image: Optional[str]): message = Message() if image: - _image = image.replace('link://', '') + if image.startswith('link://'): + _image = image.replace('link://', '') + else: + logger.warning('[gscore] qqgroup暂不支持发送本地图信息, 请转为URL发送') + return else: _image = '' diff --git a/pyproject.toml b/pyproject.toml index 82158c56..1e734401 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -23,7 +23,7 @@ build-backend = "poetry.core.masonry.api" [tool.poetry] name = "nonebot-plugin-genshinuid" -version = "4.4.0" +version = "4.4.1" description = "支持OneBot(QQ)、OneBotV12、QQ频道、微信、KOOK(开黑啦)、Telegram(电报)、FeiShu(飞书)、DoDo、Villa(米游社大别野)、Discord的全功能NoneBot2原神插件" authors = ["KimigaiiWuyi <444835641@qq.com>"] license = "GPL-3.0-or-later"