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-2/miku/plugins/openingsmoe.lua

35 lines
999 B
Lua
Raw Normal View History

2016-08-17 18:29:52 +02:00
local openingsmoe = {}
openingsmoe.triggers = {
"openings.moe/%?video=(.*).webm"
}
function openingsmoe: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 nil end
if not data.success then return nil 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
local text = '<b>'..number..'</b> aus <b>'..title..'</b>\n<b>Song:</b> '..song_title..' von '..song_artist..'\n<a href="'..url..'">Direktlink</a>'
return text
end
function openingsmoe:action(msg, config, matches)
local opening = matches[1]
local text = openingsmoe:get_opening(opening)
if not text then
2016-08-24 17:18:17 +02:00
utilities.send_reply(msg, config.errors.connection)
2016-08-17 18:29:52 +02:00
return
end
2016-08-24 17:18:17 +02:00
utilities.send_reply(msg, text, 'HTML')
2016-08-17 18:29:52 +02:00
end
return openingsmoe