diff --git a/list.json b/list.json index bd9e98b..236f28c 100644 --- a/list.json +++ b/list.json @@ -1069,36 +1069,6 @@ "supported": true, "des_short": "miaolang 喵语翻译机", "des": "喵语翻译机\n\n指令:\n- `,enmiao <待转换文本> (支持回复消息)` (转换指定文本到喵语)\n- `,demiao <喵语> (支持回复消息)` (转换喵语到明文)" - }, - { - "name": "chatgpt", - "version": "1.0", - "section": "chat", - "maintainer": "xtaodada", - "size": "4.129 kb", - "supported": true, - "des_short": ":recycle: Reformat All Plugins", - "des": "" - }, - { - "name": "today_in_history", - "version": "1.0", - "section": "chat", - "maintainer": "xtaodada", - "size": "2.643 kb", - "supported": true, - "des_short": ":recycle: Reformat All Plugins", - "des": "" - }, - { - "name": "trace", - "version": "1.0", - "section": "chat", - "maintainer": "xtaodada", - "size": "20.483 kb", - "supported": true, - "des_short": ":recycle: Reformat All Plugins", - "des": "" } ] } \ No newline at end of file diff --git a/update_list.py b/update_list.py index 1158ee4..8666c4f 100644 --- a/update_list.py +++ b/update_list.py @@ -26,20 +26,20 @@ delete = bool(main["commit"]["message"].startswith("Delete")) for idx, plugins_ in enumerate([plugins, alpha_plugins]): with open(f"{list_json_start[idx]}list.json", "r", encoding="utf8") as f: list_json = json.load(f) + plugin_map = {i["name"]: i for i in list_json["list"]} for plugin in plugins_: - exist = False - for plug_dict in list_json["list"]: - if plug_dict["name"] == plugin: - exist = True - old_version = decimal.Decimal(plug_dict["version"]) - plug_dict["version"] = str(old_version + decimal.Decimal("0.01")) - plug_dict[ - "size" - ] = f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb" - if delete: - list_json["list"].remove(plug_dict) - break - if not exist: + if plugin in plugin_map: + if delete: + plugin_map.pop(plugin) + list_json["list"] = list(plugin_map.values()) + continue + plug_dict = plugin_map[plugin] + old_version = decimal.Decimal(plug_dict["version"]) + plug_dict["version"] = str(old_version + decimal.Decimal("0.01")) + plug_dict[ + "size" + ] = f"{os.path.getsize(f'{list_json_start[idx]}{plugin}{os.sep}main.py') / 1000} kb" + else: short_des = main["commit"]["message"].split("\nCo-authored-by")[0].strip() list_json["list"].append( {