From 7abdac7c9c34fc6cf5f517fb964bc98cb107f077 Mon Sep 17 00:00:00 2001 From: Expliyh Date: Thu, 16 May 2024 20:28:46 +0800 Subject: [PATCH] =?UTF-8?q?statistic=E9=80=82=E9=85=8Dsatori?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/plugins/liteyuki_statistics/stat_matchers.py | 5 +++-- liteyuki/utils/satori_utils/event_tools.py | 7 +++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/liteyuki/plugins/liteyuki_statistics/stat_matchers.py b/liteyuki/plugins/liteyuki_statistics/stat_matchers.py index cbe87b7..582043a 100644 --- a/liteyuki/plugins/liteyuki_statistics/stat_matchers.py +++ b/liteyuki/plugins/liteyuki_statistics/stat_matchers.py @@ -1,6 +1,7 @@ from nonebot import Bot, require from liteyuki.utils.message.npl import convert_duration, convert_time_to_seconds from .stat_api import * +from ...utils import satori_utils from ...utils.base.language import Language from ...utils.base.ly_typing import T_MessageEvent @@ -44,7 +45,7 @@ stat_msg = on_alconna( @stat_msg.assign("message") async def _(result: Arparma, event: T_MessageEvent, bot: Bot): - ulang = Language(event.user_id) + ulang = Language(satori_utils.get_user_id(event)) try: duration = convert_time_to_seconds(result.other_args.get("duration", "2d")) # 秒数 @@ -57,7 +58,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: Bot): bot_id = result.other_args.get("bot_id") if group_id in ["current", "c"]: - group_id = str(event.group_id) + group_id = str(satori_utils.get_group_id(event)) if group_id in ["all", "a"]: group_id = "all" diff --git a/liteyuki/utils/satori_utils/event_tools.py b/liteyuki/utils/satori_utils/event_tools.py index 04930f8..dbc9423 100644 --- a/liteyuki/utils/satori_utils/event_tools.py +++ b/liteyuki/utils/satori_utils/event_tools.py @@ -8,3 +8,10 @@ def get_user_id(event: T_MessageEvent): return event.user.id else: return event.user_id + + +def get_group_id(event: T_MessageEvent): + if isinstance(event, satori.event.Event): + return event.guild.id + else: + return event.group_id