Make bots able to post at different times.

This commit is contained in:
Himanshu Goel 2023-10-09 14:06:17 -04:00
parent 18cc1a7408
commit a68470a344

View file

@ -146,7 +146,8 @@ def generate_config(defaults):
'bot_hashtags': defaults['bot_hashtags'],
'misskey_url': defaults['misskey_url'],
'misskey_token': defaults['misskey_token'],
'max_page_number': defaults['max_page_number']
'max_page_number': defaults['max_page_number'],
'last_run_time': -1,
}
with open("config.json", "w") as config_file:
@ -205,12 +206,19 @@ def main():
for key in defaults:
if key not in cfg_tmp:
cfg_tmp[key] = defaults[key]
if cfg_tmp['last_run_time'] == -1:
cfg_tmp['last_run_time'] = time.time() - 60 * 60
if cfg_tmp['last_run_time'] != -1 and time.time() - cfg_tmp['last_run_time'] < 60 * 60:
continue
try:
bot_instance = BotInstance(cfg_name, cfg_tmp)
bot_instance.bot_process(log_file)
# Save the saved image list to config.json
config[cfg_name]["max_page_number"] = bot_instance.max_page_number
# Save the last run time
config[cfg_name]["last_run_time"] = time.time()
# If error, print error and continue
except Exception as e: