Don't update timestamp if post failed.
This commit is contained in:
parent
030c8c7128
commit
952c47f2ea
|
@ -228,14 +228,18 @@ class BotInstance:
|
|||
|
||||
def bot_process(self, log_file):
|
||||
# Get a random image making sure it's not in the saved image list
|
||||
attempts = 10
|
||||
while True:
|
||||
if attempts <= 0:
|
||||
return False
|
||||
image_url, image_src, image_rating, cur_page_number = self.get_random_image(max_page_number=self.max_page_number)
|
||||
self.max_page_number = cur_page_number
|
||||
if image_url is None:
|
||||
attempts -= 1
|
||||
continue
|
||||
break
|
||||
# Download and post the image to Misskey
|
||||
self.post_image(image_url, image_src, image_rating, log_file)
|
||||
return self.post_image(image_url, image_src, image_rating, log_file)
|
||||
|
||||
def generate_config(defaults):
|
||||
if os.path.exists("config.json"):
|
||||
|
@ -318,7 +322,11 @@ def main():
|
|||
|
||||
try:
|
||||
bot_instance = BotInstance(cfg_name, cfg_tmp, log_file)
|
||||
bot_instance.bot_process(log_file)
|
||||
if not bot_instance.bot_process(log_file):
|
||||
print("\n" + cfg_name + ": Error: ", file=log_file)
|
||||
print(time.strftime("%Y-%m-%d %H:%M:%S", time.localtime()), file=log_file)
|
||||
print("Error running bot", file=log_file)
|
||||
continue
|
||||
# Save the saved image list to config.json
|
||||
config[cfg_name]["max_page_number"] = bot_instance.max_page_number
|
||||
# Save the last run time
|
||||
|
|
Loading…
Reference in New Issue