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 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
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
function facebook:send_facebook_video(video_id)
@ -144,11 +145,10 @@ function facebook:action(msg, config, matches)
else
photo_id = matches[4]
end
local text, image_url = facebook:send_facebook_photo(photo_id, receiver)
if not image_url then return end
local text = facebook:send_facebook_photo(photo_id, receiver)
if not text then return end
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_reply(msg, text, 'HTML')
utilities.send_photo(msg.chat.id, image_url, nil, msg.message_id)
utilities.send_message(msg.chat.id, text, false, msg.message_id, 'HTML')
return
elseif matches[1] == 'video' or matches[2] == 'videos' then
if not matches[3] then

View File

@ -8,41 +8,58 @@ end
function instagram:get_instagram(url)
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
local data = json.decode(res)
if data.title then
title = data.title:gsub('"', '\\"')
if data.meta.title then
title = data.meta.title:gsub('"', '\\"')
else
title = 'Kein Titel'
end
if data.description then
description = data.description:gsub('"', '\\"')
description_in_text = '\n'..description
if data.meta.description then
description = data.meta.description:gsub('"', '\\"')
description_in_text = description
else
description_in_text = ''
description = 'Keine Beschreibung verfügbar'
end
local pic = data.thumbnail_url
local text = title..'\n'..description_in_text
if data.links.player then
video = 'https:'..data.links.player[1].href
else
video = 'NOVID'
end
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 pic, text
return video, text
end
function instagram:action(msg, config, matches)
local url = matches[1]
local pic, text = instagram:get_instagram(url)
local video, text = instagram:get_instagram(url)
if not url then
utilities.send_reply(msg, 'Fehler')
return
end
utilities.send_typing(msg.chat.id, 'upload_photo')
utilities.send_photo(msg.chat.id, pic, text, msg.message_id)
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')
end
return instagram

View File

@ -38,7 +38,7 @@ function mal_user:get_infos(user)
end
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
end

View File

@ -21,9 +21,8 @@ function mc_skin:action(msg, config, matches)
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 file = download_to_file(url, input..'.png')
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)
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'
utilities.send_photo(msg.chat.id, img, nil, msg.message_id)
end
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..' erstellt eine falsche Route auf '..other_user..'s Navi.',
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())