From 274541c6cdcf0700b8a10c9f80d6ea2f30de3afc Mon Sep 17 00:00:00 2001 From: Akamaru Date: Fri, 21 Jul 2017 21:43:06 +0200 Subject: [PATCH] =?UTF-8?q?instagram:=20=C3=84nderungen=20r=C3=BCckg=C3=A4?= =?UTF-8?q?ngig=20geacht?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- miku/plugins/instagram.lua | 41 +++++++++++--------------------------- 1 file changed, 12 insertions(+), 29 deletions(-) diff --git a/miku/plugins/instagram.lua b/miku/plugins/instagram.lua index e15faf9..4b8186d 100644 --- a/miku/plugins/instagram.lua +++ b/miku/plugins/instagram.lua @@ -8,58 +8,41 @@ end function instagram:get_instagram(url) local api_key = cred_data.iframely_api_key - local res, code = https.request('https://iframe.ly/api/iframely?url=https://www.instagram.com/p/'..URL.escape(url)..'&api_key='..api_key) + local res, code = https.request('https://iframe.ly/api/oembed?url=https://www.instagram.com/p/'..URL.escape(url)..'&api_key='..api_key) if code ~= 200 then return end local data = json.decode(res) - if data.meta.title then - title = data.meta.title:gsub('"', '\\"') + if data.title then + title = data.title:gsub('"', '\\"') else title = 'Kein Titel' end - if data.meta.description then - description = data.meta.description:gsub('"', '\\"') - description_in_text = description + if data.description then + description = data.description:gsub('"', '\\"') + description_in_text = '\n'..description else description_in_text = '' description = 'Keine Beschreibung verfügbar' end - if data.links.player then - video = 'https:'..data.links.player[1].href - else - video = 'NOVID' - end - - if data.links.image then - pic = ' ' - else - pic = ' ' - end - - local text = ''..title..' '..pic..'\n'..description_in_text..'' + local pic = data.thumbnail_url + local text = title..'\n'..description_in_text - return video, text + return pic, text end function instagram:action(msg, config, matches) local url = matches[1] - local video, text = instagram:get_instagram(url) + local pic, text = instagram:get_instagram(url) if not url then utilities.send_reply(msg, 'Fehler') return end - if video == 'NOVID' then - return - else - utilities.send_typing(msg.chat.id, 'upload_video') - utilities.send_video(msg.chat.id, video, nil, msg.message_id) - end - - utilities.send_message(msg.chat.id, text, false, msg.message_id, 'html') + utilities.send_typing(msg.chat.id, 'upload_photo') + utilities.send_photo(msg.chat.id, pic, text, msg.message_id) end return instagram \ No newline at end of file