mirror of
https://github.com/himanshugoel2797/MisskeyBooruImageBot.git
synced 2024-10-22 23:19:06 +00:00
Make bots able to post at different times.
This commit is contained in:
parent
18cc1a7408
commit
a68470a344
1 changed files with 9 additions and 1 deletions
|
@ -146,7 +146,8 @@ def generate_config(defaults):
|
||||||
'bot_hashtags': defaults['bot_hashtags'],
|
'bot_hashtags': defaults['bot_hashtags'],
|
||||||
'misskey_url': defaults['misskey_url'],
|
'misskey_url': defaults['misskey_url'],
|
||||||
'misskey_token': defaults['misskey_token'],
|
'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:
|
with open("config.json", "w") as config_file:
|
||||||
|
@ -205,12 +206,19 @@ def main():
|
||||||
for key in defaults:
|
for key in defaults:
|
||||||
if key not in cfg_tmp:
|
if key not in cfg_tmp:
|
||||||
cfg_tmp[key] = defaults[key]
|
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:
|
try:
|
||||||
bot_instance = BotInstance(cfg_name, cfg_tmp)
|
bot_instance = BotInstance(cfg_name, cfg_tmp)
|
||||||
bot_instance.bot_process(log_file)
|
bot_instance.bot_process(log_file)
|
||||||
# Save the saved image list to config.json
|
# Save the saved image list to config.json
|
||||||
config[cfg_name]["max_page_number"] = bot_instance.max_page_number
|
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
|
# If error, print error and continue
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|
Loading…
Reference in a new issue