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):