From 881550f1e924d51e7c8b875addac2cdadc80de70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Ml=C3=A1dek?= Date: Sun, 28 Oct 2018 14:08:57 +0100 Subject: [PATCH] add auto tumblr, pt. 2 --- delojza.py | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/delojza.py b/delojza.py index 2ebe526..95efbc2 100755 --- a/delojza.py +++ b/delojza.py @@ -141,7 +141,7 @@ def handle_hashtag(bot, update): # noinspection PyBroadException -def handle(urls, message, download, filename=None): +def handle(urls, message, download, tumblr=False, filename=None): try: hashtag = get_first_hashtag(message) if hashtag is None: @@ -159,10 +159,15 @@ def handle(urls, message, download, filename=None): if hashtag == 'AUDIO' and download != download_raw: reply += ' (And also guessing you want to extract the audio)' message.reply_text(reply) - return download(urls, - hashtag or '.', message.date, - extract=(hashtag == 'AUDIO'), - filename=filename) + filenames = download(urls, + hashtag or '.', message.date, + extract=(hashtag == 'AUDIO'), + filename=filename) + if hashtag == 'TUMBLR': + message.reply_text('(btw, queueing to tumblr)') + for filename in filenames: + client.create_photo('kunsaxan', state="queue", data=filename) + return filenames except: _, exc_value, __ = sys.exc_info() if "Timed out" not in str(exc_value): @@ -200,11 +205,7 @@ def handle_rest(bot, update): if file is not None: url = bot.getFile(file).file_path - filenames = handle([url], update.message, download_raw, filename=filename) - if tumblr: - update.message.reply_text('(btw, queueing to tumblr)') - for filename in filenames: - client.create_photo('kunsaxan', state="queue", data=filename) + handle([url], update.message, download_raw, tumblr=tumblr, filename=filename) def handle_text(bot, update):