Integriere Telegram-Funktionen, wie sendPhoto, sendVideo, sendDocument, etc. in utilites.lua und update alle Plugins, damit sie diese Funktion nutzen

This commit is contained in:
Andreas Bielawski
2016-06-12 20:53:20 +02:00
parent df96462d03
commit 306782496e
6 changed files with 109 additions and 16 deletions

View File

@@ -26,6 +26,7 @@ function ninegag:get_9GAG()
end
function ninegag:action(msg, config)
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local url, title = ninegag:get_9GAG()
if not url then
utilities.send_reply(self, msg, config.errors.connection)
@@ -33,9 +34,7 @@ function ninegag:action(msg, config)
end
local file = download_to_file(url)
bindings.sendPhoto(self, {chat_id = msg.chat.id, caption = title}, {photo = file} )
os.remove(file)
print("Deleted: "..file)
utilities.send_photo(self, msg.chat.id, file, title)
end
return ninegag

View File

@@ -47,6 +47,7 @@ function gImages:action(msg, config)
return
end
utilities.send_typing(self, msg.chat.id, 'upload_photo')
local apikey = cred_data.google_apikey
local cseid = cred_data.google_cse_id
local BASE_URL = 'https://www.googleapis.com/customsearch/v1'
@@ -68,9 +69,7 @@ function gImages:action(msg, config)
local img_url = jdat.items[i].link
local file = download_to_file(img_url)
bindings.sendPhoto(self, {chat_id = msg.chat.id, caption = img_url}, {photo = file} )
os.remove(file)
print("Deleted: "..file)
utilities.send_photo(self, msg.chat.id, file, img_url)
end
return gImages

View File

@@ -51,7 +51,7 @@ function imdb:action(msg, config)
if jdat.Poster ~= "N/A" then
local file = download_to_file(jdat.Poster)
bindings.sendPhoto(self, {chat_id = msg.chat.id}, {photo = file} )
utilities.send_photo(self, msg.chat.id, file)
end
end

View File

@@ -140,15 +140,11 @@ function twitter:action(msg)
utilities.send_reply(self, msg, header .. "\n" .. text.."\n"..footer)
for k, v in pairs(images) do
local file = download_to_file(v)
bindings.sendPhoto(self, {chat_id = msg.chat.id}, {photo = file} )
os.remove(file)
print("Deleted: "..file)
utilities.send_photo(self, msg.chat.id, file, nil, msg.message_id)
end
for k, v in pairs(videos) do
local file = download_to_file(v)
bindings.sendVideo(self, {chat_id = msg.chat.id}, {video = file} )
os.remove(file)
print("Deleted: "..file)
utilities.send_video(self, msg.chat.id, file, nil, msg.message_id)
end
end

View File

@@ -142,9 +142,7 @@ function send_youtube_data(data, msg, self, link, sendpic)
text = text..'\nACHTUNG, In Deutschland gesperrt!'
end
local file = download_to_file(image_url)
bindings.sendPhoto(self, {chat_id = msg.chat.id, reply_to_message_id = msg.message_id, caption = text }, {photo = file} )
os.remove(file)
print("Deleted: "..file)
utilities.send_photo(self, msg.chat.id, file, text, msg.message_id)
else
utilities.send_reply(self, msg, text, true)
end