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/openings_moe.lua

35 lines
898 B
Lua

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 text
end
return {
description = "Sendet Infos zu einem Opening",
usage = "Openings.moe Link",
patterns = {"openings.moe/%?video=(.*).webm"},
run = run
}
end