add auto tumblr, pt. 2

feature-unify_handlers
Tomáš Mládek 2018-10-28 14:08:57 +01:00 committed by Tomáš Mládek
parent 45dfdac742
commit 881550f1e9
1 changed files with 11 additions and 10 deletions

View File

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