Kleine Fixes und Verbesserungen

This commit is contained in:
Akamaru 2017-05-24 21:28:05 +02:00
parent a3b54cb2a1
commit 19eb111b9f
5 changed files with 44 additions and 27 deletions

View File

@ -68,13 +68,14 @@ function facebook:send_facebook_photo(photo_id, receiver)
local data = json.decode(res) local data = json.decode(res)
local from = '<b>'..data.from.name..'</b>' local from = '<b>'..data.from.name..'</b>'
if data.name then
text = from..' hat ein Bild gepostet:\n'..data.name
else
text = from..' hat ein Bild gepostet:'
end
local image_url = data.images[1].source local image_url = data.images[1].source
return text, image_url if data.name then
text = from..'<a href="'..image_url..'"> </a>hat ein Bild gepostet:\n'..data.name
else
text = from..'<a href="'..image_url..'"> </a>hat ein Bild gepostet:'
end
return text
end end
function facebook:send_facebook_video(video_id) function facebook:send_facebook_video(video_id)
@ -144,11 +145,10 @@ function facebook:action(msg, config, matches)
else else
photo_id = matches[4] photo_id = matches[4]
end end
local text, image_url = facebook:send_facebook_photo(photo_id, receiver) local text = facebook:send_facebook_photo(photo_id, receiver)
if not image_url then return end if not text then return end
utilities.send_typing(msg.chat.id, 'upload_photo') utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_reply(msg, text, 'HTML') utilities.send_message(msg.chat.id, text, false, msg.message_id, 'HTML')
utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
return return
elseif matches[1] == 'video' or matches[2] == 'videos' then elseif matches[1] == 'video' or matches[2] == 'videos' then
if not matches[3] then if not matches[3] then

View File

@ -8,41 +8,58 @@ end
function instagram:get_instagram(url) function instagram:get_instagram(url)
local api_key = cred_data.iframely_api_key local api_key = cred_data.iframely_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) local res, code = https.request('https://iframe.ly/api/iframely?url=https://www.instagram.com/p/'..URL.escape(url)..'&api_key='..api_key)
if code ~= 200 then return end if code ~= 200 then return end
local data = json.decode(res) local data = json.decode(res)
if data.title then if data.meta.title then
title = data.title:gsub('"', '\\"') title = data.meta.title:gsub('"', '\\"')
else else
title = 'Kein Titel' title = 'Kein Titel'
end end
if data.description then if data.meta.description then
description = data.description:gsub('"', '\\"') description = data.meta.description:gsub('"', '\\"')
description_in_text = '\n'..description description_in_text = description
else else
description_in_text = '' description_in_text = ''
description = 'Keine Beschreibung verfügbar' description = 'Keine Beschreibung verfügbar'
end end
local pic = data.thumbnail_url if data.links.player then
local text = title..'\n'..description_in_text video = 'https:'..data.links.player[1].href
else
video = 'NOVID'
end
return pic, text if data.links.image then
pic = '<a href="'..data.links.image[1].href..'"> </a>'
else
pic = '<a href="'..data.links.thumbnail[2].href..'"> </a>'
end
local text = '<b>'..title..'</b> '..pic..'\n<i>'..description_in_text..'</i>'
return video, text
end end
function instagram:action(msg, config, matches) function instagram:action(msg, config, matches)
local url = matches[1] local url = matches[1]
local pic, text = instagram:get_instagram(url) local video, text = instagram:get_instagram(url)
if not url then if not url then
utilities.send_reply(msg, 'Fehler') utilities.send_reply(msg, 'Fehler')
return return
end end
utilities.send_typing(msg.chat.id, 'upload_photo') if video == 'NOVID' then
utilities.send_photo(msg.chat.id, pic, text, msg.message_id) 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')
end end
return instagram return instagram

View File

@ -38,7 +38,7 @@ function mal_user:get_infos(user)
end end
local mal_url = '<a href="http://myanimelist.net/profile/'..data.user_name..'">Profil aufrufen</a>' local mal_url = '<a href="http://myanimelist.net/profile/'..data.user_name..'">Profil aufrufen</a>'
local text = user_pic..name..user_id..' schaut derzeit '..watching..', hat '..pause..', '..dropped..' und '..complete..'. '..planed..' auf der Watchlist.\n'..mal_url local text = name..user_id..' schaut derzeit '..watching..', hat '..pause..', '..dropped..' und '..complete..'. '..planed..' auf der Watchlist.\n'..user_pic..mal_url
return text return text
end end

View File

@ -21,9 +21,8 @@ function mc_skin:action(msg, config, matches)
end end
end end
local url = 'http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=330&wt=10&abg=330&abd=40&ajg=340&ajd=20&ratio=13&format=png&login='..input..'&headOnly=false&displayHairs=true&randomness=341.png' local img = 'http://www.minecraft-skin-viewer.net/3d.php?layers=true&aa=true&a=0&w=330&wt=10&abg=330&abd=40&ajg=340&ajd=20&ratio=13&format=png&login='..input..'&headOnly=false&displayHairs=true&randomness=341.png'
local file = download_to_file(url, input..'.png') utilities.send_photo(msg.chat.id, img, nil, msg.message_id)
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
end end
return mc_skin return mc_skin

View File

@ -55,7 +55,8 @@ function fun:choose_random(user_name, other_user)
user_name..' schmiert Hundescheiße auf '..other_user..'s Nike Air.', user_name..' schmiert Hundescheiße auf '..other_user..'s Nike Air.',
user_name..' erstellt eine falsche Route auf '..other_user..'s Navi.', user_name..' erstellt eine falsche Route auf '..other_user..'s Navi.',
user_name..' zieht '..other_user..' die Hose aus.', user_name..' zieht '..other_user..' die Hose aus.',
user_name..' schenkt '..other_user..' Bibis Beauty-Cream.' user_name..' schenkt '..other_user..' Bibis Beauty-Cream.',
user_name..' schubst '..other_user..' von einer Klippe. Armer Timmy...'
} }
math.randomseed(os.time()) math.randomseed(os.time())
math.randomseed(os.time()) math.randomseed(os.time())