summaryrefslogtreecommitdiffstats
path: root/taulubot.py
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2016-05-21 17:09:23 +0300
committerJan Tuomi <jans.tuomi@gmail.com>2016-05-21 17:09:23 +0300
commitd0156660ecb28d7e168dcf8d7f621b4505c6b7ce (patch)
treef00f884339e0ada3fb4dd7f29fddd4b2cb4e3c36 /taulubot.py
parent8ca7584fa456e64d01fc931c715b9f905aa59e22 (diff)
Add chance for golden borders
Diffstat (limited to 'taulubot.py')
-rw-r--r--taulubot.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/taulubot.py b/taulubot.py
index cc52c77..88a6d90 100644
--- a/taulubot.py
+++ b/taulubot.py
@@ -1,4 +1,5 @@
import sys
+import random
import time
from pprint import pprint
import telepot
@@ -11,10 +12,12 @@ import logging
logging.basicConfig(format='%(asctime)s %(message)s')
taulu_im = Image.open("taulu.png")
+golden_im = Image.open("golden.png")
img_size = (640, 640)
START_TIME = calendar.timegm(time.gmtime())
taulu_im.thumbnail(img_size, Image.ANTIALIAS)
+golden_im.thumbnail(img_size, Image.ANTIALIAS)
def run_taulu(chat_id, user_id):
@@ -46,7 +49,13 @@ def run_taulu(chat_id, user_id):
logging.warning("Opening image for editing...")
im = Image.open(filepath)
im.thumbnail(img_size, Image.ANTIALIAS)
- im.paste(taulu_im, (0, 0), taulu_im)
+
+ # every 100th image has golden borders :)
+ if random.randrange(1, 100) == 1:
+ im.paste(golden_im, (0, 0), golden_im)
+ bot.sendMessage(chat_id, "Onneksi olkoon! Kultainen taulu ilmestyy vain kerran tuhannessa vuodessa!")
+ else:
+ im.paste(taulu_im, (0, 0), taulu_im)
logging.warning("Saving image...")
im.save(finalpath)