statistic适配satori

This commit is contained in:
Expliyh 2024-05-16 20:28:46 +08:00
parent 002df66878
commit 7abdac7c9c
No known key found for this signature in database
GPG Key ID: F30DE0CFF6157916
2 changed files with 10 additions and 2 deletions

View File

@ -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"

View File

@ -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