fixed config load
This commit is contained in:
parent
871a3ddf64
commit
7cb57d45d6
1 changed files with 14 additions and 1 deletions
15
ubot.py
15
ubot.py
|
@ -76,7 +76,20 @@ if not os.path.exists(default_config_file_path):
|
||||||
|
|
||||||
with open(default_config_file_path, "r") as configfile:
|
with open(default_config_file_path, "r") as configfile:
|
||||||
from types import SimpleNamespace
|
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)
|
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)
|
config = SimpleNamespace(**cnf_dict)
|
||||||
logger.debug('config loaded')
|
logger.debug('config loaded')
|
||||||
|
|
||||||
|
@ -102,7 +115,7 @@ class states:
|
||||||
last_sent_bioeb = 0 # for measure time between reply avocado and bioeb
|
last_sent_bioeb = 0 # for measure time between reply avocado and bioeb
|
||||||
last_reply_bioeb_avocado = 0 # same as above
|
last_reply_bioeb_avocado = 0 # same as above
|
||||||
avocado_reply_timeout = 3 # increase interval if lag more than this timeout in secs
|
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
|
latest_successfull_mine = None
|
||||||
wait_before_next_mine = None
|
wait_before_next_mine = None
|
||||||
stats_medkit = 0
|
stats_medkit = 0
|
||||||
|
|
Loading…
Reference in a new issue