1
0
forked from bot/app

feat: 自动向轻雪服务器上报错误信息

This commit is contained in:
远野千束 2024-03-24 19:15:49 +08:00
parent ccef8ca125
commit 45f9afb73c
4 changed files with 31 additions and 10 deletions

View File

@ -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,
}
)

View File

@ -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')}")

View File

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

View File

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