mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
⚡ 使用gather调用
This commit is contained in:
parent
017d21c8d8
commit
1869c0ae9d
@ -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():
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user