From 90216c1a602b68a32b623948836cf6b815288482 Mon Sep 17 00:00:00 2001 From: snowy Date: Wed, 27 Mar 2024 07:57:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E5=B9=B6=E9=87=8D?= =?UTF-8?q?=E5=90=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/liteyuki_main/core.py | 11 ++++++++--- liteyuki/resources/lang/en.lang | 3 +++ liteyuki/resources/lang/zh-CN.lang | 3 +++ 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/liteyuki/liteyuki_main/core.py b/liteyuki/liteyuki_main/core.py index aa979a4d..46fffd40 100644 --- a/liteyuki/liteyuki_main/core.py +++ b/liteyuki/liteyuki_main/core.py @@ -5,8 +5,10 @@ from git import Repo from liteyuki.utils.config import config from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent +from liteyuki.utils.language import get_user_lang +from liteyuki.utils.message import Markdown as md, send_markdown + from .reloader import Reloader -from ..utils.message import send_markdown require("nonebot_plugin_alconna") from nonebot_plugin_alconna import on_alconna, Alconna @@ -27,7 +29,7 @@ update_liteyuki = on_alconna( reload_liteyuki = on_alconna( Alconna( - ["reload-liteyuki", "重启轻雪"] + ["reload-liteyuki", "restart-liteyuki", "重启轻雪"] ), permission=SUPERUSER ) @@ -41,6 +43,7 @@ async def _(bot: T_Bot): @update_liteyuki.handle() async def _(bot: T_Bot, event: T_MessageEvent): # 使用git pull更新 + ulang = get_user_lang(str(event.user_id)) origins = ["origin", "origin2"] repo = Repo(".") for origin in origins: @@ -51,7 +54,9 @@ async def _(bot: T_Bot, event: T_MessageEvent): print(f"Pull from {origin} failed: {e}") logs = repo.index.diff() reply = "Liteyuki updated!\n" - reply += f"```\n{logs}\n```" + reply += f"```\n{logs}\n```\n" + btn_restart = md.button(ulang.get("liteyuki.restart"), "restart-liteyuki") + reply += f"{ulang.get('liteyuki.update_restart', RESTART=btn_restart)}" await send_markdown(reply, bot, event=event, at_sender=False) diff --git a/liteyuki/resources/lang/en.lang b/liteyuki/resources/lang/en.lang index 4bf1a7a0..0555608a 100644 --- a/liteyuki/resources/lang/en.lang +++ b/liteyuki/resources/lang/en.lang @@ -6,6 +6,9 @@ log.warning=WARN log.error=Error log.success=Success +liteyuki.restart=Restart +liteyuki.update_restart=Update completely, You can {RESTART} the server now or later + main.current_language=Current config language: {LANG} main.enable_webdash=Web dashboard is enabled: {URL} main.monitor.title=Liteyuki Monitor diff --git a/liteyuki/resources/lang/zh-CN.lang b/liteyuki/resources/lang/zh-CN.lang index 21876224..ce5cd8b4 100644 --- a/liteyuki/resources/lang/zh-CN.lang +++ b/liteyuki/resources/lang/zh-CN.lang @@ -6,6 +6,9 @@ log.warning=警告 log.error=错误 log.success=成功 +liteyuki.restart=重启 +liteyuki.update_restart=更新完成,你可以立即{RESTART}或稍后手动重启以应用这些更新 + main.current_language=当前配置语言为: {LANG} main.enable_webdash=已启用网页监控面板: {URL} main.monitor.title=轻雪监控面板