mirror of
https://github.com/TriM-Organization/LiteyukiBot-TriM.git
synced 2024-12-01 09:44:44 +08:00
feat: 自动向轻雪服务器上报错误信息
This commit is contained in:
parent
ccef8ca125
commit
45f9afb73c
@ -4,6 +4,7 @@ from liteyuki.utils.language import get_default_lang
|
|||||||
from liteyuki.utils.data_manager import *
|
from liteyuki.utils.data_manager import *
|
||||||
from .loader import *
|
from .loader import *
|
||||||
from .webdash import *
|
from .webdash import *
|
||||||
|
from .core import *
|
||||||
from liteyuki.utils.config import config
|
from liteyuki.utils.config import config
|
||||||
|
|
||||||
__author__ = "snowykami"
|
__author__ = "snowykami"
|
||||||
@ -13,7 +14,7 @@ __plugin_meta__ = PluginMetadata(
|
|||||||
usage="",
|
usage="",
|
||||||
homepage="https://github.com/snowykami/LiteyukiBot",
|
homepage="https://github.com/snowykami/LiteyukiBot",
|
||||||
extra={
|
extra={
|
||||||
"liteyuki": True,
|
"liteyuki" : True,
|
||||||
"toggleable": False,
|
"toggleable": False,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
17
liteyuki/liteyuki_main/core.py
Normal file
17
liteyuki/liteyuki_main/core.py
Normal 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')}")
|
@ -52,7 +52,7 @@ async def _(event: T_MessageEvent, bot: T_Bot):
|
|||||||
|
|
||||||
session_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)
|
default_enable = get_plugin_default_enable(plugin.module_name)
|
||||||
print(session_enable, default_enable, plugin.module_name)
|
|
||||||
|
|
||||||
if store_plugin:
|
if store_plugin:
|
||||||
btn_homepage = md.link(lang.get('npm.homepage'), store_plugin.homepage)
|
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")
|
plugin_module_name = result.args.get("plugin_name")
|
||||||
|
|
||||||
toggle = result.header_result == 'enable-plugin' # 判断是启用还是停用
|
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) # 获取插件默认状态
|
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:
|
if not can_be_toggled:
|
||||||
await toggle_plugin.finish(ulang.get("npm.plugin_cannot_be_toggled", NAME=plugin_module_name))
|
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(
|
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")))
|
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)
|
session.disabled_plugins.append(plugin_module_name)
|
||||||
else:
|
else:
|
||||||
session.enabled_plugins.remove(plugin_module_name)
|
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:
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
await toggle_plugin.finish(
|
await toggle_plugin.finish(
|
||||||
ulang.get(
|
ulang.get(
|
||||||
"npm.toggle_failed",
|
"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"))
|
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
|
@run_preprocessor
|
||||||
async def _(event: T_MessageEvent, matcher: Matcher):
|
async def _(event: T_MessageEvent, matcher: Matcher):
|
||||||
|
@ -7,7 +7,7 @@ import sys
|
|||||||
import pickle
|
import pickle
|
||||||
|
|
||||||
__NAME__ = "LiteyukiBot"
|
__NAME__ = "LiteyukiBot"
|
||||||
__VERSION__ = "6.2.3" # 60201
|
__VERSION__ = "6.2.4" # 60201
|
||||||
|
|
||||||
import psutil
|
import psutil
|
||||||
import requests
|
import requests
|
||||||
@ -25,6 +25,7 @@ def register_bot():
|
|||||||
"version" : __VERSION__,
|
"version" : __VERSION__,
|
||||||
"version_i": __VERSION_I__,
|
"version_i": __VERSION_I__,
|
||||||
"python" : f"{platform.python_implementation()} {platform.python_version()}",
|
"python" : f"{platform.python_implementation()} {platform.python_version()}",
|
||||||
|
"os" : f"{platform.system()} {platform.version()} {platform.machine()}"
|
||||||
}
|
}
|
||||||
try:
|
try:
|
||||||
nonebot.logger.info("Waiting for register to Liteyuki...")
|
nonebot.logger.info("Waiting for register to Liteyuki...")
|
||||||
|
Loading…
Reference in New Issue
Block a user