app/liteyuki/plugins/liteyuki_status/status.py

50 lines
1.3 KiB
Python
Raw Normal View History

from liteyuki.utils import event as event_utils
2024-06-02 13:58:41 +08:00
from liteyuki.utils.base.language import get_user_lang
from liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent
2024-06-02 13:58:41 +08:00
from .api import *
2024-04-22 23:55:33 +08:00
2024-04-12 13:07:19 +08:00
require("nonebot_plugin_alconna")
2024-06-02 13:58:41 +08:00
from nonebot_plugin_alconna import on_alconna, Alconna, Subcommand, UniMessage
2024-04-12 13:07:19 +08:00
status_alc = on_alconna(
2024-04-26 15:02:46 +08:00
aliases={"状态"},
2024-04-12 13:07:19 +08:00
command=Alconna(
2024-04-26 15:02:46 +08:00
"status",
2024-04-12 13:07:19 +08:00
Subcommand(
"memory",
alias={"mem", "m", "内存"},
),
Subcommand(
"process",
alias={"proc", "p", "进程"},
)
),
)
2024-04-22 23:55:33 +08:00
@status_alc.handle()
async def _(event: T_MessageEvent, bot: T_Bot):
ulang = get_user_lang(event_utils.get_user_id(event))
2024-04-30 15:23:12 +08:00
if ulang.lang_code in status_card_cache:
image = status_card_cache[ulang.lang_code]
else:
image = await generate_status_card(
bot=await get_bots_data(),
hardware=await get_hardware_data(),
liteyuki=await get_liteyuki_data(),
lang=ulang.lang_code,
bot_id=bot.self_id,
use_cache=True
)
2024-04-22 23:55:33 +08:00
await status_alc.finish(UniMessage.image(raw=image))
2024-04-12 13:07:19 +08:00
@status_alc.assign("memory")
async def _():
print("memory")
@status_alc.assign("process")
async def _():
print("process")