mirror of
https://github.com/KimigaiiWuyi/GenshinUID.git
synced 2025-05-12 06:55:58 +08:00
🏷️ 支持更多适配器, 修复已知问题
This commit is contained in:
parent
db2ea4dc68
commit
858057b150
@ -41,6 +41,8 @@ def _get_bot(bot_id: str) -> Bot:
|
|||||||
bot_id = 'onebotv12'
|
bot_id = 'onebotv12'
|
||||||
elif 'red' in bot_id:
|
elif 'red' in bot_id:
|
||||||
bot_id = 'RedProtocol'
|
bot_id = 'RedProtocol'
|
||||||
|
elif 'qqguild' in bot_id:
|
||||||
|
bot_id = 'qq'
|
||||||
# bots: Dict[str, str] 以适配器名称为键、bot_self_id为值的字典
|
# bots: Dict[str, str] 以适配器名称为键、bot_self_id为值的字典
|
||||||
_refresh_bots()
|
_refresh_bots()
|
||||||
if bot_id not in bots:
|
if bot_id not in bots:
|
||||||
@ -623,11 +625,19 @@ async def guild_send(
|
|||||||
msg_id: Optional[str],
|
msg_id: Optional[str],
|
||||||
guild_id: Optional[str],
|
guild_id: Optional[str],
|
||||||
):
|
):
|
||||||
|
from nonebot.adapters.qq.exception import ActionFailed
|
||||||
|
from nonebot.adapters.qq.bot import Bot as qqbot
|
||||||
|
|
||||||
|
assert isinstance(bot, qqbot)
|
||||||
|
|
||||||
async def _send(content: Optional[str], image: Optional[str]):
|
async def _send(content: Optional[str], image: Optional[str]):
|
||||||
result: Dict[str, Any] = {'msg_id': msg_id}
|
result: Dict[str, Any] = {'msg_id': msg_id}
|
||||||
if image:
|
if image:
|
||||||
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
if image.startswith('link://'):
|
||||||
result['file_image'] = img_bytes
|
result['image'] = image.replace('link://', '')
|
||||||
|
else:
|
||||||
|
img_bytes = base64.b64decode(image.replace('base64://', ''))
|
||||||
|
result['file_image'] = img_bytes
|
||||||
if content:
|
if content:
|
||||||
result['content'] = content
|
result['content'] = content
|
||||||
if at_list and target_type == 'group':
|
if at_list and target_type == 'group':
|
||||||
@ -639,22 +649,25 @@ async def guild_send(
|
|||||||
logger.warning('[gscore] qqguild暂不支持发送buttons消息')
|
logger.warning('[gscore] qqguild暂不支持发送buttons消息')
|
||||||
|
|
||||||
if target_type == 'group':
|
if target_type == 'group':
|
||||||
await bot.call_api(
|
await bot.post_messages(
|
||||||
'post_messages',
|
|
||||||
channel_id=str(target_id) if target_id else 0,
|
channel_id=str(target_id) if target_id else 0,
|
||||||
**result,
|
**result,
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
dms = await bot.call_api(
|
try:
|
||||||
'post_dms',
|
await bot.post_dms_messages(
|
||||||
recipient_id=str(target_id),
|
guild_id=str(guild_id),
|
||||||
source_guild_id=str(guild_id),
|
**result,
|
||||||
)
|
)
|
||||||
await bot.call_api(
|
except ActionFailed:
|
||||||
'post_dms_messages',
|
dms = await bot.post_dms(
|
||||||
guild_id=dms.guild_id,
|
recipient_id=str(target_id),
|
||||||
**result,
|
source_guild_id=str(guild_id),
|
||||||
)
|
)
|
||||||
|
await bot.post_dms_messages(
|
||||||
|
guild_id=dms.guild_id,
|
||||||
|
**result,
|
||||||
|
)
|
||||||
|
|
||||||
if node:
|
if node:
|
||||||
for _msg in node:
|
for _msg in node:
|
||||||
|
@ -23,8 +23,8 @@ build-backend = "poetry.core.masonry.api"
|
|||||||
|
|
||||||
[tool.poetry]
|
[tool.poetry]
|
||||||
name = "nonebot-plugin-genshinuid"
|
name = "nonebot-plugin-genshinuid"
|
||||||
version = "4.3.1"
|
version = "4.4.0"
|
||||||
description = "支持OneBot(QQ)、OneBotV12、QQ频道、微信、KOOK(开黑啦)、Telegram(电报)、FeiShu(飞书)的全功能NoneBot2原神插件"
|
description = "支持OneBot(QQ)、OneBotV12、QQ频道、微信、KOOK(开黑啦)、Telegram(电报)、FeiShu(飞书)、DoDo、Villa(米游社大别野)、Discord的全功能NoneBot2原神插件"
|
||||||
authors = ["KimigaiiWuyi <444835641@qq.com>"]
|
authors = ["KimigaiiWuyi <444835641@qq.com>"]
|
||||||
license = "GPL-3.0-or-later"
|
license = "GPL-3.0-or-later"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user