diff options
| author | Jan Tuomi <jans.tuomi@gmail.com> | 2016-05-21 17:21:54 +0300 |
|---|---|---|
| committer | Jan Tuomi <jans.tuomi@gmail.com> | 2016-05-21 17:21:54 +0300 |
| commit | a203b78d4b5d9d4ca05614160752987b5866ea4b (patch) | |
| tree | 373f56dfb2dccde4f0d361128ea54246c2a495e7 /taulubot.py | |
| parent | 38abc8a0f2b840e4f00651fece5bed95d5aface6 (diff) | |
Fix golden bug
Diffstat (limited to 'taulubot.py')
| -rw-r--r-- | taulubot.py | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/taulubot.py b/taulubot.py index c0c5c8e..5030e71 100644 --- a/taulubot.py +++ b/taulubot.py @@ -39,7 +39,13 @@ def run_taulu(chat_id, user_id): # download to a file with user_id in the name for duplicate recognition filepath = "photo/" + str(abs(user_id)) + ".jpg" finalpath = "photo/" + str(abs(user_id)) + "final.png" - if os.path.exists(finalpath): + + # every 100th image has golden borders :) + golden_chance = random.randrange(1, 100) + logging.warning("Random gold number was: {}".format(golden_chance)) + is_golden = (golden_chance == 1) + + if os.path.exists(finalpath) and not is_golden: logging.warning("User profile already found. Skipping download and edit...") else: logging.warning("Downloading picture...") @@ -50,10 +56,8 @@ def run_taulu(chat_id, user_id): im = Image.open(filepath) im.thumbnail(img_size, Image.ANTIALIAS) - # every 100th image has golden borders :) - golden_chance = random.randrange(1, 100) - logging.warning("Random gold number was: {}".format(golden_chance)) - if golden_chance == 1: + if is_golden: + logging.warning("Golden taulu!") im.paste(golden_im, (0, 0), golden_im) bot.sendMessage(chat_id, "Onneksi olkoon! Kultainen taulu ilmestyy vain kerran tuhannessa vuodessa!") else: |
