added more config options & made python type-safe(r).

This commit is contained in:
2025-06-26 11:16:17 +02:00
parent 486b88d90e
commit fa76443735
17 changed files with 132 additions and 102 deletions
+9 -7
View File
@@ -4,12 +4,12 @@ import time
from macros import *
import bot as botPy
import data
import py_data
import py_websocket
async def main():
sys.stdout.reconfigure(encoding="utf-8")
sys.stdout.reconfigure(encoding="utf-8") # type: ignore
py_print("Creating Reddit bot...")
bot = botPy.Bot()
@@ -20,8 +20,10 @@ async def main():
# args is supposed to be undefined.
# It gets defined in Rust.
try:
await bot.set_args(args)
init_lang(lang_name)
await bot.set_args(args) # type: ignore
py_print("Fetching language file...")
init_lang(lang_name) # type: ignore
py_print(f"[IMPORTANT] The below message is a test message, it should be written in the language you've selected\nTest message: {lang('log_lang_load_success')}")
except NameError:
py_print("No command args or language name found from Rust. Don't worry though, we have backup in place.")
init_lang("en")
@@ -30,17 +32,17 @@ async def main():
py_print("ARGS:", str(bot.args))
py_print("Reading config file...")
await data.read_cfg(bot)
await py_data.read_cfg(bot)
py_print("Reading Reddit data...")
rd = data.read_data(bot)
rd = py_data.read_data(bot)
data_retries = 0
while not rd :
data_retries += 1
time.sleep(1)
py_print(f"Failed to read data: File doesn't exist yet. Retrying (#{data_retries}/5)...")
rd = data.read_data(bot)
rd = py_data.read_data(bot)
if data_retries == 5 and not rd:
raise Exception("Couldn't read re_data.json: File doesn't exist")