Merge pull request #33 from MoeSnowyFox/main

一些修改
This commit is contained in:
Snowykami 2024-04-18 23:27:49 +08:00 committed by GitHub
commit 5c1170f6fb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 79 additions and 4 deletions

View File

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

View File

@ -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 <plugin_name>')}*\n"
f"\n{btn_uninstall_}"
f"\n>*{md.escape('npm uninstall <plugin_name>')}*\n"
f"\n{btn_search}"
f"\n>*{md.escape('npm search <keywords...>')}*\n"
f"\n{btn_disable_global}"
f"\n>*{md.escape('npm disable-global <plugin_name>')}*\n"
f"\n{btn_enable_global}"
f"\n>*{md.escape('npm enable-global <plugin_name>')}*\n"
f"\n{btn_uninstall_}"
f"\n>*{md.escape('npm uninstall <plugin_name>')}*\n"
f"\n{btn_disable}"
f"\n>*{md.escape('npm disable <plugin_name>')}*\n"
f"\n{btn_enable}"
f"\n>*{md.escape('npm enable <plugin_name>')}*\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 <plugin_name>')}*\n"
f"\n{btn_enable}"
f"\n>*{md.escape('npm enable <plugin_name>')}*\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(

View File

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

View File

@ -127,3 +127,14 @@ rpm.move_top=置顶
weather.city_not_found=未找到城市 {CITY}
weather.weather_not_found=未找到城市 {CITY} 的天气信息
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帮助