do
local function get_opening(opening)
local url = 'http://openings.moe/api/details.php?file='..opening..'.webm'
local res,code = http.request(url)
local data = json:decode(res)
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local number = data.title
local title = data.source
local song_title = data.song.title
local song_artist = data.song.artist
local url = 'http://openings.moe/video/'..data.filename
text = number..' aus '..title..'\n'..'Song: '..song_title..' von '..song_artist..'\n'..url
return text
end
local function run(msg, matches)
local receiver = get_receiver(msg)
local opening = matches[1]
local text = get_opening(opening)
return {
description = "Sendet Infos zu einem Opening",
usage = "Openings.moe Link",
patterns = {"openings.moe/%?video=(.*).webm"},
run = run
}