This repository has been archived on 2021-04-24. You can view files and clone it, but cannot push or open issues or pull requests.
Mikubot/plugins/facebook_video.lua
2015-11-12 17:42:03 +01:00

40 lines
1.1 KiB
Lua

-- This is a proprietary plugin, property of Andreas Bielawski, (c) 2015 <andi (dot) b (at) outlook (dot) de>
-- DO NOT USE WITHOUT PERMISSION
do
local BASE_URL = 'https://graph.facebook.com'
function get_fbvid_data (fbvid_code)
local access_token = cred_data.fb_access_token
local url = BASE_URL..'/'..fbvid_code..'?access_token='..access_token..'&locale=de_DE'
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_fbvid_data(data, receiver)
local from = data.from.name
local description = data.description
local source = data.source
local text = from..' hat ein Video gepostet:\n'..description..'\n'..source
send_msg(receiver, text, ok_cb, false)
end
function run(msg, matches)
local fbvid_code = matches[1]
local data = get_fbvid_data(fbvid_code)
local receiver = get_receiver(msg)
send_fbvid_data(data, receiver)
end
return {
description = "Sendet Facebook-Video.",
usage = {"Link zu einem Video auf Facebook"},
patterns = {"facebook.com/video.php%?v=([0-9-]+)"},
run = run
}
end