From d4a2145036615e971e86f527f404904f6dfde2c7 Mon Sep 17 00:00:00 2001 From: Profitroll <47523801+profitrollgame@users.noreply.github.com> Date: Thu, 11 Aug 2022 20:39:03 +0200 Subject: [PATCH] A few strings fixed --- main.py | 9 ++++++--- modules/utils.py | 6 ++++-- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 6418f42..85d5e9d 100644 --- a/main.py +++ b/main.py @@ -146,13 +146,16 @@ def send_content(): else: sent = app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting")) # type: ignore + else: + return + list_sent["sent"].append(candidate_file) jsonSave(list_sent, configGet("index", "locations")) if configGet("move_sent", "posting"): shutil.move(candidate, configGet("sent", "locations")+os.sep+candidate_file) - logWrite(locale("post_sent", "console", locale=configGet("locale")).format(candidate, ext_type, str(configGet("channel", "posting")), caption.replace("\n", "%n"), str(configGet("silent", "posting")))) + logWrite(locale("post_sent", "console", locale=configGet("locale")).format(candidate, ext_type, str(configGet("channel", "posting")), caption.replace("\n", "%n"), str(configGet("silent", "posting")))) # type: ignore if configGet("sent", "reports"): app.send_message(configGet("admin"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([ @@ -371,12 +374,12 @@ if __name__ == "__main__": commands_list = [] for command in configGet("commands"): commands_list.append(BotCommand(command, locale(command, "commands", locale=entry.replace(".json", "")))) - app.set_bot_commands(commands_list, language_code=entry.replace(".json", "")) + app.set_bot_commands(commands_list, language_code=entry.replace(".json", "")) # type: ignore commands_list = [] for command in configGet("commands"): commands_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale_fallback")))) - app.set_bot_commands(commands_list) + app.set_bot_commands(commands_list) # type: ignore app.set_bot_commands([ # type: ignore BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))), diff --git a/modules/utils.py b/modules/utils.py index 51a46ae..71f278e 100644 --- a/modules/utils.py +++ b/modules/utils.py @@ -9,7 +9,7 @@ import os import sys import traceback -from signal import SIGKILL +from signal import SIGKILL # type: ignore from modules.logging import logWrite def jsonLoad(filename): @@ -19,8 +19,10 @@ def jsonLoad(filename): output = json.loads(file.read()) except JSONDecodeError: logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{traceback.print_exc()}") + raise except FileNotFoundError: logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{traceback.print_exc()}") + raise file.close() return output @@ -68,7 +70,7 @@ def configGet(key: str, *args: str): this_key = this_key[dict_key] return this_key[key] -def locale(key: str, *args: list, locale=configGet("locale")): +def locale(key: str, *args: str, locale=configGet("locale")): """Get value of locale string Args: * key (str): The last key of the locale's keys path.