使用gather调用

This commit is contained in:
HibiKier 2025-02-12 23:19:03 +08:00
parent 017d21c8d8
commit 1869c0ae9d
2 changed files with 12 additions and 5 deletions

View File

@ -48,7 +48,11 @@ async def _(matcher: Matcher, message: UniMsg, session: EventSession):
return
if text := message.extract_plain_text().strip():
if plugin := await PluginInfo.get_or_none(
name=text, load_status=True, plugin_type=PluginType.NORMAL
name=text,
load_status=True,
plugin_type=PluginType.NORMAL,
block_type__isnull=True,
status=True,
):
image = None
if _path.exists():

View File

@ -1,3 +1,4 @@
import asyncio
from datetime import datetime, timedelta
import time
@ -65,10 +66,12 @@ class ApiDataSource:
self_id=bot.self_id, nickname=nickname, ava_url=ava_url, platform=platform
)
try:
group_list, _ = await PlatformUtils.get_group_list(bot, True)
friend_list, _ = await PlatformUtils.get_friend_list(bot)
bot_info.group_count = len(group_list)
bot_info.friend_count = len(friend_list)
group, friend = await asyncio.gather(
PlatformUtils.get_group_list(bot, True),
PlatformUtils.get_friend_list(bot),
)
bot_info.group_count = len(group[0])
bot_info.friend_count = len(friend[0])
except Exception as e:
logger.warning("获取bot好友/群组信息失败...", "WebUi", e=e)
bot_info.group_count = 0