From 7cb57d45d612af9bf2e45c42c3dd880d0ffa6a6f Mon Sep 17 00:00:00 2001 From: Your Name Date: Wed, 18 Dec 2024 12:38:45 +0300 Subject: [PATCH] fixed config load --- ubot.py | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/ubot.py b/ubot.py index bc23170..317adcc 100644 --- a/ubot.py +++ b/ubot.py @@ -76,7 +76,20 @@ if not os.path.exists(default_config_file_path): with open(default_config_file_path, "r") as configfile: from types import SimpleNamespace + default_params = {'api_id': '1', + 'api_hash': 'test', + 'timezone': 'Etc/UTC', + 'db_pymysql': False, + 'db_sqlite3': True, + 'a_h': True, + 'a_404_patient': True, + 'automine': True} cnf_dict = json.load(configfile) + for i in default_params.keys(): + if cnf_dict.get(i) is None: + default_val = default_params[i] + cnf_dict[i] = default_val + logger.warning(f'{i} in config not found, using defalt value {default_val}') config = SimpleNamespace(**cnf_dict) logger.debug('config loaded') @@ -102,7 +115,7 @@ class states: last_sent_bioeb = 0 # for measure time between reply avocado and bioeb last_reply_bioeb_avocado = 0 # same as above avocado_reply_timeout = 3 # increase interval if lag more than this timeout in secs - automine_enabled = config.automine or True + automine_enabled = config.automine latest_successfull_mine = None wait_before_next_mine = None stats_medkit = 0