🐛 npm显示异常

This commit is contained in:
snowy 2024-04-20 04:42:11 +08:00
parent 4dd3b4aedc
commit 7585a5473d
2 changed files with 70 additions and 66 deletions

View File

@ -254,7 +254,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
) )
elif sc.get("uninstall") and perm_s: elif sc.get("uninstall") and perm_s:
plugin_name: str = result.subcommands["uninstall"].args.get("plugin_name") plugin_name: str = result.subcommands["uninstall"].args.get("plugin_name") # type: ignore
found_installed_plugin: InstalledPlugin = plugin_db.first(InstalledPlugin(), "module_name = ?", plugin_name) found_installed_plugin: InstalledPlugin = plugin_db.first(InstalledPlugin(), "module_name = ?", plugin_name)
if found_installed_plugin: if found_installed_plugin:
plugin_db.delete(InstalledPlugin(), "module_name = ?", plugin_name) plugin_db.delete(InstalledPlugin(), "module_name = ?", plugin_name)
@ -286,16 +286,16 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
store_plugin = await get_store_plugin(storePlugin.name) store_plugin = await get_store_plugin(storePlugin.name)
session_enable = get_plugin_session_enable(event, storePlugin.name) session_enable = get_plugin_session_enable(event, storePlugin.name)
if store_plugin: if store_plugin:
btn_homepage = md.btn_link(ulang.get("npm.homepage"), store_plugin.homepage) # btn_homepage = md.btn_link(ulang.get("npm.homepage"), store_plugin.homepage)
show_name = store_plugin.name show_name = store_plugin.name
elif storePlugin.metadata: elif storePlugin.metadata:
if storePlugin.metadata.extra.get("liteyuki"): # if storePlugin.metadata.extra.get("liteyuki"):
btn_homepage = md.btn_link(ulang.get("npm.homepage"), "https://github.com/snowykami/LiteyukiBot") # btn_homepage = md.btn_link(ulang.get("npm.homepage"), "https://github.com/snowykami/LiteyukiBot")
else: # else:
btn_homepage = ulang.get("npm.homepage") # btn_homepage = ulang.get("npm.homepage")
show_name = storePlugin.metadata.name show_name = storePlugin.metadata.name
else: else:
btn_homepage = ulang.get("npm.homepage") # btn_homepage = ulang.get("npm.homepage")
show_name = storePlugin.name show_name = storePlugin.name
ulang.get("npm.no_description") ulang.get("npm.no_description")
@ -304,7 +304,7 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
else: else:
reply += f"**{md.escape(show_name)}**\n" reply += f"**{md.escape(show_name)}**\n"
reply += f"\n > {btn_usage} {btn_homepage}" reply += f"\n > {btn_usage}"
if permission_oas: if permission_oas:
# 添加启用/停用插件按钮 # 添加启用/停用插件按钮
@ -347,26 +347,26 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
reply = ( reply = (
f"\n# **{ulang.get('npm.help')}**" f"\n# **{ulang.get('npm.help')}**"
f"\n{btn_update}" f"\n{btn_update}"
f"\n>*{md.escape('npm update')}*\n" f"\n\n>*{md.escape('npm update')}*\n"
f"\n{btn_install_}" f"\n{btn_install_}"
f"\n>*{md.escape('npm install <plugin_name>')}*\n" f"\n\n>*{md.escape('npm install <plugin_name>')}*\n"
f"\n{btn_uninstall_}" f"\n{btn_uninstall_}"
f"\n>*{md.escape('npm uninstall <plugin_name>')}*\n" f"\n\n>*{md.escape('npm uninstall <plugin_name>')}*\n"
f"\n{btn_search}" f"\n{btn_search}"
f"\n>*{md.escape('npm search <keywords...>')}*\n" f"\n\n>*{md.escape('npm search <keywords...>')}*\n"
f"\n{btn_disable_global}" f"\n{btn_disable_global}"
f"\n>*{md.escape('npm disable-global <plugin_name>')}*\n" f"\n\n>*{md.escape('npm disable-global <plugin_name>')}*\n"
f"\n{btn_enable_global}" f"\n{btn_enable_global}"
f"\n>*{md.escape('npm enable-global <plugin_name>')}*\n" f"\n\n>*{md.escape('npm enable-global <plugin_name>')}*\n"
f"\n{btn_uninstall_}" f"\n{btn_uninstall_}"
f"\n>*{md.escape('npm uninstall <plugin_name>')}*\n" f"\n\n>*{md.escape('npm uninstall <plugin_name>')}*\n"
f"\n{btn_disable}" f"\n{btn_disable}"
f"\n>*{md.escape('npm disable <plugin_name>')}*\n" f"\n\n>*{md.escape('npm disable <plugin_name>')}*\n"
f"\n{btn_enable}" f"\n{btn_enable}"
f"\n>*{md.escape('npm enable <plugin_name>')}*\n" f"\n\n>*{md.escape('npm enable <plugin_name>')}*\n"
f"\n{btn_list}" f"\n{btn_list}"
f"\n>page为页数num为每页显示数量" f"\n\n>page为页数num为每页显示数量"
f"\n>*{md.escape('npm list [page] [num]')}*" f"\n\n>*{md.escape('npm list [page] [num]')}*"
) )
await md.send_md(reply, bot, event=event) await md.send_md(reply, bot, event=event)
else: else:
@ -377,14 +377,13 @@ async def _(result: Arparma, event: T_MessageEvent, bot: T_Bot, npm: Matcher):
reply = ( reply = (
f"\n# **{ulang.get('npm.help')}**" f"\n# **{ulang.get('npm.help')}**"
f"\n{btn_disable}" f"\n{btn_disable}"
f"\n>*{md.escape('npm disable <plugin_name>')}*\n" f"\n\n>*{md.escape('npm disable <plugin_name>')}*\n"
f"\n{btn_enable}" f"\n{btn_enable}"
f"\n>*{md.escape('npm enable <plugin_name>')}*\n" f"\n\n>*{md.escape('npm enable <plugin_name>')}*\n"
f"\n{btn_list}" f"\n{btn_list}"
f"\n>page为页数num为每页显示数量" f"\n\n>page为页数num为每页显示数量"
f"\n>*{md.escape('npm list [page] [num]')}*" f"\n\n>*{md.escape('npm list [page] [num]')}*"
) )
await md.send_md(reply, bot, event=event) await md.send_md(reply, bot, event=event)
@ -465,13 +464,23 @@ async def _(result: Arparma, matcher: Matcher, event: T_MessageEvent, bot: T_Bot
module_name=plugin_name, module_name=plugin_name,
homepage="" homepage=""
) )
if store_plugin:
link = store_plugin.homepage
elif loaded_plugin.metadata.extra.get("liteyuki"):
link = "https://github.com/snowykami/LiteyukiBot"
else:
link = None
reply = [ reply = [
mdc.heading(escape_md(loaded_plugin.metadata.name)), mdc.heading(escape_md(store_plugin.name)),
mdc.quote(store_plugin.module_name),
mdc.quote(mdc.bold(ulang.get("npm.author")) + " " + mdc.quote(mdc.bold(ulang.get("npm.author")) + " " +
(mdc.link(store_plugin.author, f"https://github.com/{store_plugin.author}") if store_plugin.author else "Unknown")), (mdc.link(store_plugin.author, f"https://github.com/{store_plugin.author}") if store_plugin.author else "Unknown")),
mdc.quote(mdc.bold(ulang.get("npm.description")) + " " + mdc.paragraph(max(loaded_plugin.metadata.description, store_plugin.desc))), mdc.quote(mdc.bold(ulang.get("npm.description")) + " " + mdc.paragraph(max(loaded_plugin.metadata.description, store_plugin.desc))),
mdc.heading(ulang.get("npm.usage"), 2), mdc.heading(ulang.get("npm.usage"), 2),
mdc.paragraph(escape_md(loaded_plugin.metadata.usage)), mdc.quote(escape_md(loaded_plugin.metadata.usage)),
mdc.link(ulang.get("npm.homepage"), link) if link else mdc.paragraph(ulang.get("npm.no_homepage"))
] ]
await md.send_md(compile_md(reply), bot, event=event) await md.send_md(compile_md(reply), bot, event=event)
else: else:

View File

@ -128,13 +128,8 @@ weather.city_not_found=未找到城市 {CITY}
weather.weather_not_found=未找到城市 {CITY} 的天气信息 weather.weather_not_found=未找到城市 {CITY} 的天气信息
weather.no_key=未设置天气api key请在配置文件添加weather-key weather.no_key=未设置天气api key请在配置文件添加weather-key
npm.enable_global = 全局启用插件 npm.update_index=更新插件商店索引
npm.disable_global = 全局停用插件 npm.list_plugins=列出所有插件
npm.search = 搜索插件 npm.disable_session=当前会话停用插件
npm.uninstall = 卸载插件 npm.enable_session=当前会话启用插件
npm.install = 安装插件 npm.help=帮助
npm.update_index = 更新插件商店索引
npm.list_plugins = 列出所有插件
npm.disable_session = 当前会话停用插件
npm.enable_session = 当前会话启用插件
npm.help = npm帮助