add auto tumblr, pt. 2
This commit is contained in:
parent
45dfdac742
commit
881550f1e9
1 changed files with 11 additions and 10 deletions
21
delojza.py
21
delojza.py
|
@ -141,7 +141,7 @@ def handle_hashtag(bot, update):
|
||||||
|
|
||||||
|
|
||||||
# noinspection PyBroadException
|
# noinspection PyBroadException
|
||||||
def handle(urls, message, download, filename=None):
|
def handle(urls, message, download, tumblr=False, filename=None):
|
||||||
try:
|
try:
|
||||||
hashtag = get_first_hashtag(message)
|
hashtag = get_first_hashtag(message)
|
||||||
if hashtag is None:
|
if hashtag is None:
|
||||||
|
@ -159,10 +159,15 @@ def handle(urls, message, download, filename=None):
|
||||||
if hashtag == 'AUDIO' and download != download_raw:
|
if hashtag == 'AUDIO' and download != download_raw:
|
||||||
reply += ' (And also guessing you want to extract the audio)'
|
reply += ' (And also guessing you want to extract the audio)'
|
||||||
message.reply_text(reply)
|
message.reply_text(reply)
|
||||||
return download(urls,
|
filenames = download(urls,
|
||||||
hashtag or '.', message.date,
|
hashtag or '.', message.date,
|
||||||
extract=(hashtag == 'AUDIO'),
|
extract=(hashtag == 'AUDIO'),
|
||||||
filename=filename)
|
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:
|
except:
|
||||||
_, exc_value, __ = sys.exc_info()
|
_, exc_value, __ = sys.exc_info()
|
||||||
if "Timed out" not in str(exc_value):
|
if "Timed out" not in str(exc_value):
|
||||||
|
@ -200,11 +205,7 @@ def handle_rest(bot, update):
|
||||||
|
|
||||||
if file is not None:
|
if file is not None:
|
||||||
url = bot.getFile(file).file_path
|
url = bot.getFile(file).file_path
|
||||||
filenames = handle([url], update.message, download_raw, filename=filename)
|
handle([url], update.message, download_raw, tumblr=tumblr, filename=filename)
|
||||||
if tumblr:
|
|
||||||
update.message.reply_text('(btw, queueing to tumblr)')
|
|
||||||
for filename in filenames:
|
|
||||||
client.create_photo('kunsaxan', state="queue", data=filename)
|
|
||||||
|
|
||||||
|
|
||||||
def handle_text(bot, update):
|
def handle_text(bot, update):
|
||||||
|
|
Loading…
Reference in a new issue