add auto tumblr, pt. 2
This commit is contained in:
parent
45dfdac742
commit
881550f1e9
1 changed files with 11 additions and 10 deletions
15
delojza.py
15
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,
|
||||
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):
|
||||
|
|
Loading…
Reference in a new issue