diff --git a/liteyuki/liteyuki_main/runtime.py b/liteyuki/liteyuki_main/runtime.py index 16fe1d1..e6cc34e 100644 --- a/liteyuki/liteyuki_main/runtime.py +++ b/liteyuki/liteyuki_main/runtime.py @@ -12,6 +12,8 @@ from liteyuki.utils.base.language import Language, get_default_lang_code, get_us from liteyuki.utils.base.ly_typing import T_Bot, T_MessageEvent from liteyuki.utils.base.resource import get_path from liteyuki.utils.message.tools import convert_size +from PIL import Image +from io import BytesIO stats = on_command("status", aliases={"状态"}, priority=5, permission=SUPERUSER) @@ -37,10 +39,21 @@ async def _(bot: T_Bot, event: T_MessageEvent): }, wait=1 ) + image = await png_to_jpg(image) await stats.finish(MessageSegment.image(image)) -async def get_bots_data(ulang: Language, self_id: "") -> list: +async def png_to_jpg(image): + image_stream = BytesIO(image) + img = Image.open(image_stream) + rgb_img = img.convert('RGB') + output_stream = BytesIO() + rgb_img.save(output_stream, format='JPEG') + jpg_bytes = output_stream.getvalue() + return jpg_bytes + + +async def get_bots_data(ulang: Language, self_id) -> list: bots_data = [] for bot_id, bot in nonebot.get_bots().items(): groups = 0 diff --git a/liteyuki/plugins/liteyuki_pacman/npm.py b/liteyuki/plugins/liteyuki_pacman/npm.py index 0b16db6..299d3ee 100644 --- a/liteyuki/plugins/liteyuki_pacman/npm.py +++ b/liteyuki/plugins/liteyuki_pacman/npm.py @@ -334,7 +334,58 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher): await md.send_md(reply, bot, event=event) else: - await npm.finish(ulang.get("liteyuki.invalid_command")) + if await SUPERUSER(bot, event): + btn_enable_global = md.btn_cmd(ulang.get("npm.enable_global"), "npm enable-global", False, False) + btn_disable_global = md.btn_cmd(ulang.get("npm.disable_global"), "npm disable-global", False, False) + btn_search = md.btn_cmd(ulang.get("npm.search"), "npm search ", False, False) + btn_uninstall_ = md.btn_cmd(ulang.get("npm.uninstall"), "npm uninstall ", False, False) + btn_install_ = md.btn_cmd(ulang.get("npm.install"), "npm install ", False, False) + btn_update = md.btn_cmd(ulang.get("npm.update_index"), "npm update", False, True) + btn_list = md.btn_cmd(ulang.get("npm.list_plugins"), "npm list ", False, False) + btn_disable = md.btn_cmd(ulang.get("npm.disable_session"), "npm disable ", False, False) + btn_enable = md.btn_cmd(ulang.get("npm.enable_session"), "npm enable ", False, False) + reply = ( + f"\n# **{ulang.get('npm.help')}**" + f"\n{btn_update}" + f"\n>*{md.escape('npm update')}*\n" + f"\n{btn_install_}" + f"\n>*{md.escape('npm install ')}*\n" + f"\n{btn_uninstall_}" + f"\n>*{md.escape('npm uninstall ')}*\n" + f"\n{btn_search}" + f"\n>*{md.escape('npm search ')}*\n" + f"\n{btn_disable_global}" + f"\n>*{md.escape('npm disable-global ')}*\n" + f"\n{btn_enable_global}" + f"\n>*{md.escape('npm enable-global ')}*\n" + f"\n{btn_uninstall_}" + f"\n>*{md.escape('npm uninstall ')}*\n" + f"\n{btn_disable}" + f"\n>*{md.escape('npm disable ')}*\n" + f"\n{btn_enable}" + f"\n>*{md.escape('npm enable ')}*\n" + f"\n{btn_list}" + f"\n>page为页数,num为每页显示数量" + f"\n>*{md.escape('npm list [page] [num]')}*" + ) + await md.send_md(reply, bot, event=event) + else: + + btn_list = md.btn_cmd(ulang.get("npm.list_plugins"), "npm list ", False, False) + btn_disable = md.btn_cmd(ulang.get("npm.disable_session"), "npm disable ", False, False) + btn_enable = md.btn_cmd(ulang.get("npm.enable_session"), "npm enable ", False, False) + reply = ( + f"\n# **{ulang.get('npm.help')}**" + f"\n{btn_disable}" + f"\n>*{md.escape('npm disable ')}*\n" + f"\n{btn_enable}" + f"\n>*{md.escape('npm enable ')}*\n" + f"\n{btn_list}" + f"\n>page为页数,num为每页显示数量" + f"\n>*{md.escape('npm list [page] [num]')}*" + ) + + await md.send_md(reply, bot, event=event) @on_alconna( diff --git a/liteyuki/plugins/liteyuki_pacman/rpm.py b/liteyuki/plugins/liteyuki_pacman/rpm.py index 5c81027..612345b 100644 --- a/liteyuki/plugins/liteyuki_pacman/rpm.py +++ b/liteyuki/plugins/liteyuki_pacman/rpm.py @@ -167,5 +167,5 @@ async def _(bot: T_Bot, event: T_MessageEvent, result: Arparma): ulang.get("liteyuki.list_resources"), f"rpm list" ) - reply += f"{btn_list} {btn_reload}" + reply += f"{btn_list} \n {btn_reload}" await md.send_md(reply, bot, event=event) diff --git a/liteyuki/resources/lang/zh-CN.lang b/liteyuki/resources/lang/zh-CN.lang index 10a4df6..7ed30f6 100644 --- a/liteyuki/resources/lang/zh-CN.lang +++ b/liteyuki/resources/lang/zh-CN.lang @@ -126,4 +126,15 @@ rpm.move_top=置顶 weather.city_not_found=未找到城市 {CITY} weather.weather_not_found=未找到城市 {CITY} 的天气信息 -weather.no_key=未设置天气api key,请在配置文件添加weather-key \ No newline at end of file +weather.no_key=未设置天气api key,请在配置文件添加weather-key + +npm.enable_global = 全局启用插件 +npm.disable_global = 全局停用插件 +npm.search = 搜索插件 +npm.uninstall = 卸载插件 +npm.install = 安装插件 +npm.update_index = 更新插件商店索引 +npm.list_plugins = 列出所有插件 +npm.disable_session = 当前会话停用插件 +npm.enable_session = 当前会话启用插件 +npm.help = npm帮助