feat: 配置项目的热修改

This commit is contained in:
2024-03-31 06:22:53 +08:00
parent c8851bd696
commit f9e61fd184
22 changed files with 86394 additions and 138 deletions

View File

@ -10,7 +10,7 @@ from nonebot import require
from nonebot.permission import SUPERUSER
from liteyuki.utils.language import get_user_lang
from liteyuki.utils.ly_typing import T_Bot
from liteyuki.utils.message import Markdown as md, send_markdown
from liteyuki.utils.message import Markdown as md
from .common import *
require("nonebot_plugin_alconna")
@ -81,7 +81,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
reply += f"\n{ulang.get('npm.too_many_results', HIDE_NUM=len(rs) - max_show)}"
else:
reply = ulang.get("npm.search_no_result")
await send_markdown(reply, bot, event=event)
await md.send_md(reply, bot, event=event)
elif result.subcommands.get("install"):
plugin_module_name: str = result.subcommands["install"].args.get("plugin_name")
@ -104,7 +104,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
if found_in_db_plugin is None:
plugin_db.upsert(installed_plugin)
info = md.escape(ulang.get("npm.install_success", NAME=store_plugin.name)) # markdown转义
await send_markdown(
await md.send_md(
f"{info}\n\n"
f"```\n{log}\n```",
bot,
@ -114,7 +114,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
await npm_alc.finish(ulang.get("npm.plugin_already_installed", NAME=store_plugin.name))
else:
info = ulang.get("npm.load_failed", NAME=plugin_module_name, HOMEPAGE=homepage_btn).replace("_", r"\\_")
await send_markdown(
await md.send_md(
f"{info}\n\n"
f"```\n{log}\n```\n",
bot,
@ -122,7 +122,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot):
)
else:
info = ulang.get("npm.install_failed", NAME=plugin_module_name, HOMEPAGE=homepage_btn).replace("_", r"\\_")
await send_markdown(
await md.send_md(
f"{info}\n\n"
f"```\n{log}\n```",
bot,

View File

@ -13,7 +13,7 @@ from nonebot.plugin import Plugin
from liteyuki.utils.data_manager import GlobalPlugin, Group, InstalledPlugin, User, group_db, plugin_db, user_db
from liteyuki.utils.language import get_user_lang
from liteyuki.utils.ly_typing import T_Bot, T_MessageEvent
from liteyuki.utils.message import Markdown as md, send_markdown
from liteyuki.utils.message import Markdown as md
from liteyuki.utils.permission import GROUP_ADMIN, GROUP_OWNER
from .common import get_plugin_can_be_toggle, get_plugin_default_enable, get_plugin_global_enable, get_plugin_session_enable
from .installer import get_store_plugin, npm_update
@ -107,7 +107,7 @@ async def _(event: T_MessageEvent, bot: T_Bot):
reply += f" {btn_uninstall} {btn_toggle_global}"
reply += "\n\n***\n"
await send_markdown(reply, bot, event=event)
await md.send_md(reply, bot, event=event)
@toggle_plugin.handle()
@ -228,6 +228,6 @@ async def pre_handle(event: Event, matcher: Matcher):
raise IgnoredException("Plugin disabled in session")
@Bot.on_calling_api
async def _(bot: Bot, api: str, data: dict[str, any]):
nonebot.logger.info(f"Plugin Callapi: {api}: {data}")
# @Bot.on_calling_api
# async def _(bot: Bot, api: str, data: dict[str, any]):
# nonebot.logger.info(f"Plugin Callapi: {api}: {data}")