diff --git a/HSMensaW_botA.py b/HSMensaW_botA.py index 29dab4b..401339a 100644 --- a/HSMensaW_botA.py +++ b/HSMensaW_botA.py @@ -373,11 +373,16 @@ def get_now() -> str: return datetime.datetime.now().strftime("%Y-%m-%d %H:%M:%S") -def as_enum(d): +def process_json(d: dict) -> Any: if "Language" in d: lang = d["Language"] return getattr(Language, lang) else: + if isinstance(d, dict): + try: + return {int(k): v for k, v in d.items()} + except ValueError: + return d return d @@ -393,7 +398,7 @@ translator = Translator() try: with open(config_filename, 'r') as config_file: - config = json.load(config_file, object_hook=as_enum) + config = json.load(config_file, object_hook=process_json) except FileNotFoundError as e: print('Error: config file "{}" not found: {}'.format(config_filename, e)) sys.exit(-1)