Functions for downloading and removing images async. The magic of cackbacks 🌟

This commit is contained in:
yago
2015-02-15 14:06:01 +01:00
parent 8ee6e8fd4f
commit 3df9d9c3f3
3 changed files with 99 additions and 40 deletions

View File

@@ -22,7 +22,7 @@ function run(msg, matches)
local receiver = get_receiver(msg)
url, title = get_9GAG()
file_path = download_to_file(url)
send_photo(receiver, file_path, send_title, {receiver, title})
_send_photo(receiver, file_path, send_title, {receiver, title})
return false
end

View File

@@ -59,14 +59,10 @@ function run(msg, matches)
-- send the parts
local receiver = get_receiver(msg)
send_msg(receiver, header .. "\n" .. text, ok_cb, false)
for k, v in pairs(images) do
local file = download_to_file(v)
send_photo(receiver, file, ok_cb, false)
delay_s(1)
end
send_photos_from_url(receiver, images)
return nil
end
return {
description = "When user sends twitter URL, send text and images to origin. Requieres OAuth Key.",