From 45f9afb73cf4be0fc6cfd37c8d97fbc534c39066 Mon Sep 17 00:00:00 2001 From: snowy Date: Sun, 24 Mar 2024 19:15:49 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=87=AA=E5=8A=A8=E5=90=91=E8=BD=BB?= =?UTF-8?q?=E9=9B=AA=E6=9C=8D=E5=8A=A1=E5=99=A8=E4=B8=8A=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- liteyuki/liteyuki_main/__init__.py | 3 ++- liteyuki/liteyuki_main/core.py | 17 +++++++++++++++++ liteyuki/plugins/liteyuki_npm/manager.py | 18 ++++++++++-------- liteyuki/utils/__init__.py | 3 ++- 4 files changed, 31 insertions(+), 10 deletions(-) create mode 100644 liteyuki/liteyuki_main/core.py diff --git a/liteyuki/liteyuki_main/__init__.py b/liteyuki/liteyuki_main/__init__.py index 7e5006d8..b996ff87 100644 --- a/liteyuki/liteyuki_main/__init__.py +++ b/liteyuki/liteyuki_main/__init__.py @@ -4,6 +4,7 @@ from liteyuki.utils.language import get_default_lang from liteyuki.utils.data_manager import * from .loader import * from .webdash import * +from .core import * from liteyuki.utils.config import config __author__ = "snowykami" @@ -13,7 +14,7 @@ __plugin_meta__ = PluginMetadata( usage="", homepage="https://github.com/snowykami/LiteyukiBot", extra={ - "liteyuki": True, + "liteyuki" : True, "toggleable": False, } ) diff --git a/liteyuki/liteyuki_main/core.py b/liteyuki/liteyuki_main/core.py new file mode 100644 index 00000000..e6b8d8b3 --- /dev/null +++ b/liteyuki/liteyuki_main/core.py @@ -0,0 +1,17 @@ +from nonebot.permission import SUPERUSER +from nonebot_plugin_alconna import Alconna, Arparma, on_alconna + +from liteyuki.utils.config import config +from liteyuki.utils.ly_typing import T_Bot + +cmd_liteyuki = on_alconna( + Alconna( + "liteyuki" + ), + permission=SUPERUSER +) + + +@cmd_liteyuki.handle() +async def _(bot: T_Bot): + await cmd_liteyuki.finish(f"Hello, Liteyuki!\nBot {bot.self_id}\nLiteyukiID {config.get('liteyuki_id', 'No')}") diff --git a/liteyuki/plugins/liteyuki_npm/manager.py b/liteyuki/plugins/liteyuki_npm/manager.py index 42507d81..04d2a163 100644 --- a/liteyuki/plugins/liteyuki_npm/manager.py +++ b/liteyuki/plugins/liteyuki_npm/manager.py @@ -52,7 +52,7 @@ async def _(event: T_MessageEvent, bot: T_Bot): session_enable = get_plugin_session_enable(event, plugin.module_name) default_enable = get_plugin_default_enable(plugin.module_name) - print(session_enable, default_enable, plugin.module_name) + if store_plugin: btn_homepage = md.link(lang.get('npm.homepage'), store_plugin.homepage) @@ -115,7 +115,8 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): plugin_module_name = result.args.get("plugin_name") toggle = result.header_result == 'enable-plugin' # 判断是启用还是停用 - current_enable = get_plugin_session_enable(event, plugin_module_name) # 获取插件当前状态 + + session_enable = get_plugin_session_enable(event, plugin_module_name) # 获取插件当前状态 default_enable = get_plugin_default_enable(plugin_module_name) # 获取插件默认状态 @@ -124,7 +125,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): if not can_be_toggled: await toggle_plugin.finish(ulang.get("npm.plugin_cannot_be_toggled", NAME=plugin_module_name)) - if current_enable == toggle: + if session_enable == toggle: await toggle_plugin.finish( ulang.get("npm.plugin_already", NAME=plugin_module_name, STATUS=ulang.get("npm.enable") if toggle else ulang.get("npm.disable"))) @@ -146,7 +147,13 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): session.disabled_plugins.append(plugin_module_name) else: session.enabled_plugins.remove(plugin_module_name) + if event.message_type == "private": + print("已保存") + user_db.upsert(session) + else: + group_db.upsert(session) except Exception as e: + print(e) await toggle_plugin.finish( ulang.get( "npm.toggle_failed", @@ -162,11 +169,6 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot): STATUS=ulang.get("npm.enable") if toggle else ulang.get("npm.disable")) ) - if event.message_type == "private": - user_db.upsert(session) - else: - group_db.upsert(session) - @run_preprocessor async def _(event: T_MessageEvent, matcher: Matcher): diff --git a/liteyuki/utils/__init__.py b/liteyuki/utils/__init__.py index 1bd878dc..67724e36 100644 --- a/liteyuki/utils/__init__.py +++ b/liteyuki/utils/__init__.py @@ -7,7 +7,7 @@ import sys import pickle __NAME__ = "LiteyukiBot" -__VERSION__ = "6.2.3" # 60201 +__VERSION__ = "6.2.4" # 60201 import psutil import requests @@ -25,6 +25,7 @@ def register_bot(): "version" : __VERSION__, "version_i": __VERSION_I__, "python" : f"{platform.python_implementation()} {platform.python_version()}", + "os" : f"{platform.system()} {platform.version()} {platform.machine()}" } try: nonebot.logger.info("Waiting for register to Liteyuki...")