A few strings fixed

This commit is contained in:
Profitroll 2022-08-11 20:39:03 +02:00
parent 3cd33b4769
commit d4a2145036
2 changed files with 10 additions and 5 deletions

View File

@ -146,13 +146,16 @@ def send_content():
else: else:
sent = app.send_video(configGet("channel", "posting"), candidate, caption=caption, disable_notification=configGet("silent", "posting")) # type: ignore 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) list_sent["sent"].append(candidate_file)
jsonSave(list_sent, configGet("index", "locations")) jsonSave(list_sent, configGet("index", "locations"))
if configGet("move_sent", "posting"): if configGet("move_sent", "posting"):
shutil.move(candidate, configGet("sent", "locations")+os.sep+candidate_file) 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"): if configGet("sent", "reports"):
app.send_message(configGet("admin"), f"Posted `{candidate_file}`", disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup([ 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 = [] commands_list = []
for command in configGet("commands"): for command in configGet("commands"):
commands_list.append(BotCommand(command, locale(command, "commands", locale=entry.replace(".json", "")))) 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 = [] commands_list = []
for command in configGet("commands"): for command in configGet("commands"):
commands_list.append(BotCommand(command, locale(command, "commands", locale=configGet("locale_fallback")))) 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 app.set_bot_commands([ # type: ignore
BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))), BotCommand("reboot", locale("reboot", "commands_admin", locale=configGet("locale"))),

View File

@ -9,7 +9,7 @@ import os
import sys import sys
import traceback import traceback
from signal import SIGKILL from signal import SIGKILL # type: ignore
from modules.logging import logWrite from modules.logging import logWrite
def jsonLoad(filename): def jsonLoad(filename):
@ -19,8 +19,10 @@ def jsonLoad(filename):
output = json.loads(file.read()) output = json.loads(file.read())
except JSONDecodeError: except JSONDecodeError:
logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{traceback.print_exc()}") logWrite(f"Could not load json file {filename}: file seems to be incorrect!\n{traceback.print_exc()}")
raise
except FileNotFoundError: except FileNotFoundError:
logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{traceback.print_exc()}") logWrite(f"Could not load json file {filename}: file does not seem to exist!\n{traceback.print_exc()}")
raise
file.close() file.close()
return output return output
@ -68,7 +70,7 @@ def configGet(key: str, *args: str):
this_key = this_key[dict_key] this_key = this_key[dict_key]
return this_key[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 """Get value of locale string
Args: Args:
* key (str): The last key of the locale's keys path. * key (str): The last key of the locale's keys path.