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/vine.lua
2015-11-12 17:42:03 +01:00

44 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://vine.co/oembed.json'
function get_vine_data (vine_code)
local url = BASE_URL..'?url=https://vine.co/v/'..vine_code
print(url)
local res,code = https.request(url)
if code ~= 200 then return "HTTP-FEHLER" end
local data = json:decode(res)
return data
end
function send_vine_data(data, receiver)
local title = data.title
local author_name = data.author_name
local text = '"'..title..'", hochgeladen von '..author_name
local image_url = data.thumbnail_url
local cb_extra = {
receiver=receiver,
url=image_url
}
send_msg(receiver, text, send_photo_from_url_callback, cb_extra)
end
function run(msg, matches)
local vine_code = matches[1]
local data = get_vine_data(vine_code)
local receiver = get_receiver(msg)
send_vine_data(data, receiver)
end
return {
description = "Sendet Vine-Info.",
usage = {"vine.co/v Link"},
patterns = {"vine.co/v/([A-Za-z0-9-_-]+)"},
run = run
}
end