mirror of
https://github.com/zhenxun-org/zhenxun_bot.git
synced 2025-12-15 14:22:55 +08:00
更新插件商店
This commit is contained in:
parent
fabc7444df
commit
627f02fd22
@ -256,10 +256,9 @@ class ShopManage:
|
|||||||
result = await AsyncHttpx.gather_download_file(
|
result = await AsyncHttpx.gather_download_file(
|
||||||
req_download_urls, req_paths
|
req_download_urls, req_paths
|
||||||
)
|
)
|
||||||
for _id, success in enumerate(result):
|
for success in result:
|
||||||
if not success:
|
if not success:
|
||||||
raise Exception("插件依赖文件下载失败")
|
raise Exception("插件依赖文件下载失败")
|
||||||
else:
|
|
||||||
logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理")
|
logger.debug(f"插件依赖文件列表: {req_paths}", "插件管理")
|
||||||
install_requirement(plugin_path)
|
install_requirement(plugin_path)
|
||||||
return True
|
return True
|
||||||
@ -389,9 +388,12 @@ class ShopManage:
|
|||||||
"""
|
"""
|
||||||
data: dict[str, StorePluginInfo] = await cls.get_data()
|
data: dict[str, StorePluginInfo] = await cls.get_data()
|
||||||
plugin_list = list(data.keys())
|
plugin_list = list(data.keys())
|
||||||
update_list = []
|
update_failed_list = []
|
||||||
|
update_success_list = []
|
||||||
|
result = "--已更新{}个插件 {}个失败 {}个成功--"
|
||||||
logger.info(f"尝试更新全部插件 {plugin_list}", "插件管理")
|
logger.info(f"尝试更新全部插件 {plugin_list}", "插件管理")
|
||||||
for plugin_key in plugin_list:
|
for plugin_key in plugin_list:
|
||||||
|
try:
|
||||||
plugin_info = data[plugin_key]
|
plugin_info = data[plugin_key]
|
||||||
plugin_list = await cls.get_loaded_plugins("module", "version")
|
plugin_list = await cls.get_loaded_plugins("module", "version")
|
||||||
suc_plugin = {p[0]: (p[1] or "Unknown") for p in plugin_list}
|
suc_plugin = {p[0]: (p[1] or "Unknown") for p in plugin_list}
|
||||||
@ -412,12 +414,25 @@ class ShopManage:
|
|||||||
plugin_info.is_dir,
|
plugin_info.is_dir,
|
||||||
is_external,
|
is_external,
|
||||||
)
|
)
|
||||||
update_list.append(plugin_key)
|
update_success_list.append(plugin_key)
|
||||||
if len(update_list) == 0:
|
except Exception as e:
|
||||||
|
logger.error(f"更新插件 {plugin_key} 失败: {e}", "插件管理")
|
||||||
|
update_failed_list.append(plugin_key)
|
||||||
|
if not update_success_list and not update_failed_list:
|
||||||
return "全部插件已是最新版本"
|
return "全部插件已是最新版本"
|
||||||
return "已更新插件 {}\n共计{}个插件! 重启后生效".format(
|
if update_success_list:
|
||||||
"\n- ".join(update_list), len(update_list)
|
result += "\n* 以下插件更新成功:\n\t- {}".format(
|
||||||
|
"\n\t- ".join(update_success_list)
|
||||||
)
|
)
|
||||||
|
if update_failed_list:
|
||||||
|
result += "\n* 以下插件更新失败:\n\t- {}".format(
|
||||||
|
"\n\t- ".join(update_failed_list)
|
||||||
|
)
|
||||||
|
return result.format(
|
||||||
|
len([*update_success_list,*update_failed_list]),
|
||||||
|
len(update_failed_list),
|
||||||
|
len(update_success_list),
|
||||||
|
) + "\n重启后生效"
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
async def _resolve_plugin_key(cls, plugin_id: int | str) -> str:
|
async def _resolve_plugin_key(cls, plugin_id: int | str) -> str:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user