From 68ec55fced9b67814b728f70daf2b577dcf904e8 Mon Sep 17 00:00:00 2001 From: Unbewohnte Date: Fri, 19 Aug 2022 15:43:24 +0300 Subject: [PATCH] Don't sleep on the last image --- vis.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/vis.py b/vis.py index 5613f61..bb20fbc 100755 --- a/vis.py +++ b/vis.py @@ -12,7 +12,7 @@ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR I ''' -import vk_api, os, random, datetime, argparse +import vk_api, os, random, argparse from vk_api import VkUpload from time import sleep @@ -48,7 +48,7 @@ def sendImages(img_dir = ".", ID = 0, IS_GROUP_CHAT = False, TOKEN = ""): upload_img = upload.photo_messages(photos = path_to_image)[0] # each message will contain "Counter : {number_of_}" - MESSAGE = "▶ Counter ┃{}┃ ◀".format(counter) + MESSAGE = "┃{}/{}┃".format(counter, len(files)) # sending print("• {}: Sending {}...".format(counter,filename)) @@ -69,10 +69,11 @@ def sendImages(img_dir = ".", ID = 0, IS_GROUP_CHAT = False, TOKEN = ""): print(e) continue - counter += 1 + if counter < len(files): + # giving API a bit of rest + sleep(random.uniform(3.0,4.0)) - # giving API a bit of rest - sleep(random.uniform(3.0,4.0)) + counter += 1 pass