fixed config load

This commit is contained in:
Your Name 2024-12-18 12:38:45 +03:00
parent 871a3ddf64
commit 7cb57d45d6

15
ubot.py
View file

@ -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