From d0156660ecb28d7e168dcf8d7f621b4505c6b7ce Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sat, 21 May 2016 17:09:23 +0300 Subject: Add chance for golden borders --- taulubot.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'taulubot.py') 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) -- cgit v1.3