From 454481ecc9d34babdeac820c9591e6a99696b873 Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 29 Dec 2023 20:49:54 +0800 Subject: [PATCH] :bookmark: Update to v1.4.6 :bug: Fix lang command --- languages/built-in/en.yml | 18 +++++++++--------- languages/built-in/ja.yml | 9 +++++++++ languages/built-in/zh-tw.yml | 9 +++++++++ pagermaid/__init__.py | 4 ++-- pagermaid/config.py | 7 +++++-- pagermaid/modules/help.py | 5 +++-- 6 files changed, 37 insertions(+), 15 deletions(-) diff --git a/languages/built-in/en.yml b/languages/built-in/en.yml index 591c298..893b344 100644 --- a/languages/built-in/en.yml +++ b/languages/built-in/en.yml @@ -344,15 +344,15 @@ apt_plugin_maintainer: Author apt_plugin_size: size apt_plugin_support: support period apt_plugin_des_short: description -apt_source_des: Add or delete or view the source of the plugin repository. -apt_source_parameters: "[add/del] [source url]" -apt_source_not_found: Something went wrong ~ The specified source does not exist. -apt_source_header: "Apt Source List:" -apt_source_add_success: Add success -apt_source_del_success: Del success -apt_source_add_failed: Add failed, this source already exists -apt_source_add_invalid: Add failed, invalid source -apt_source_del_failed: Del failed, this source does not exist +apt_source_des: "Add/Del/View Custom Plugin Sources." +apt_source_parameters: "[add/del] [custom plugin source links]" +apt_source_not_found: There is currently no custom plugin source. +apt_source_header: "Current custom plugin source:" +apt_source_add_success: Add successful. +apt_source_del_success: Del successful. +apt_source_add_failed: Add failed, this source already exists. +apt_source_add_invalid: Add failed, this source is invalid. +apt_source_del_failed: Deletion failed, this source does not exist. #prune ## prune prune_des: Replying to a message with this command will delete all messages between the latest message and the message. Limit, 1000 messages based on message ID, more than 1000 messages may trigger the limit of deleting messages too quickly. (Non-group administrators only delete their own messages) diff --git a/languages/built-in/ja.yml b/languages/built-in/ja.yml index bf11cb0..149760f 100644 --- a/languages/built-in/ja.yml +++ b/languages/built-in/ja.yml @@ -344,6 +344,15 @@ apt_plugin_maintainer: Author apt_plugin_size: size apt_plugin_support: support period apt_plugin_des_short: descriptionの +apt_source_des: "カスタムプラグインソースの追加/削除/表示。" +apt_source_parameters: "[add/del] [カスタムプラグインのソースリンク]" +apt_source_not_found: 現在、カスタムプラグインソースはありません。 +apt_source_header: "現在のカスタムプラグインソース:" +apt_source_add_success: 追加に成功しました。 +apt_source_del_success: 削除しました。 +apt_source_add_failed: 追加に失敗しました。このソースは既に存在します。 +apt_source_add_invalid: 追加に失敗しました。このソースは無効です。 +apt_source_del_failed: 削除に失敗しました。このソースは存在しません。 #prune ## prune prune_des: Replying to a message with this command will delete all messages between the latest message and the message. Limit, 1000 messages based on message ID, more than 1000 messages may trigger the limit of deleting messages too quickly. (Non-group administrators only delete their messages) diff --git a/languages/built-in/zh-tw.yml b/languages/built-in/zh-tw.yml index 1900741..975af7f 100644 --- a/languages/built-in/zh-tw.yml +++ b/languages/built-in/zh-tw.yml @@ -344,6 +344,15 @@ apt_plugin_maintainer: 作者 apt_plugin_size: 容量 apt_plugin_support: 支援週期 apt_plugin_des_short: 說明 +apt_source_des: "新增/刪除/檢視 自訂插件來源" +apt_source_parameters: "[add/del] [自訂軟體來源連結]" +apt_source_not_found: 目前沒有自訂插件來源 +apt_source_header: "當前自訂插件來源:" +apt_source_add_success: 添加成功 +apt_source_del_success: 刪除成功 +apt_source_add_failed: 新增失敗,此來源已存在 +apt_source_add_invalid: 新增失敗,此來源無效 +apt_source_del_failed: 刪除失敗,此來源不存在 #prune ## prune prune_des: 刪除回覆的訊息後的所有消息。 diff --git a/pagermaid/__init__.py b/pagermaid/__init__.py index 370c3d7..02a3140 100644 --- a/pagermaid/__init__.py +++ b/pagermaid/__init__.py @@ -22,8 +22,8 @@ from pagermaid.scheduler import scheduler import pyromod.listen from pyrogram import Client -pgm_version = "1.4.5" -pgm_version_code = 1405 +pgm_version = "1.4.6" +pgm_version_code = 1406 CMD_LIST = {} module_dir = __path__[0] working_dir = getcwd() diff --git a/pagermaid/config.py b/pagermaid/config.py index 6fb94d3..f183e07 100644 --- a/pagermaid/config.py +++ b/pagermaid/config.py @@ -1,11 +1,14 @@ import os import sys from json import load as load_json +from pathlib import Path from shutil import copyfile from typing import Dict from yaml import load, FullLoader, safe_load +CONFIG_PATH = Path("data/config.yml") + def strtobool(val, default=False): """Convert a string representation of truth to true (1) or false (0). @@ -25,12 +28,12 @@ def strtobool(val, default=False): try: - config: Dict = load(open(r"data/config.yml", encoding="utf-8"), Loader=FullLoader) + config: Dict = load(open(CONFIG_PATH, encoding="utf-8"), Loader=FullLoader) except FileNotFoundError: print( "The configuration file does not exist, and a new configuration file is being generated." ) - copyfile(f"{os.getcwd()}{os.sep}config.gen.yml", "data/config.yml") + copyfile(f"{os.getcwd()}{os.sep}config.gen.yml", CONFIG_PATH) sys.exit(1) diff --git a/pagermaid/modules/help.py b/pagermaid/modules/help.py index a92766e..b548de7 100644 --- a/pagermaid/modules/help.py +++ b/pagermaid/modules/help.py @@ -5,6 +5,7 @@ from pyrogram.enums import ParseMode from pagermaid import help_messages, Config from pagermaid.common.alias import AliasManager +from pagermaid.config import CONFIG_PATH from pagermaid.group_manager import enforce_permission from pagermaid.common.reload import reload_all from pagermaid.utils import lang, Message, from_self, from_msg_get_sudo_uid @@ -163,12 +164,12 @@ async def lang_change(message: Message): for i in dir_: if i.find("yml") != -1: dir__.append(i[:-4]) - file = pathlib.Path("config.yml").read_text() + file = CONFIG_PATH.read_text() if to_lang in dir__: file = file.replace( f'application_language: "{from_lang}"', f'application_language: "{to_lang}"' ) - with open("config.yml", "w", encoding="utf-8") as f: + with open(CONFIG_PATH, "w", encoding="utf-8") as f: f.write(file) await message.edit(f"{lang('lang_change_to')} {to_lang}, {lang('lang_reboot')}") await reload_all()