justkitten & openingsmoe portiert
This commit is contained in:
parent
557405af2f
commit
39b35fcf1d
26
miku/plugins/justkitten.lua
Normal file
26
miku/plugins/justkitten.lua
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
local jk = {}
|
||||||
|
|
||||||
|
function jk:init(config)
|
||||||
|
jk.triggers = utilities.triggers(self.info.username, config.cmd_pat):t('jk', true).table
|
||||||
|
jk.doc = '\n*/jk*'
|
||||||
|
end
|
||||||
|
|
||||||
|
jk.command = 'jk'
|
||||||
|
|
||||||
|
function jk:action(msg, config)
|
||||||
|
local JK_URL = 'https://anditest.perseus.uberspace.de/plugins/jk'
|
||||||
|
local jk_pics = {
|
||||||
|
"/justkitten1.jpg",
|
||||||
|
"/justkitten2.jpg",
|
||||||
|
"/justkitten3.jpg",
|
||||||
|
"/justkitten4.jpg",
|
||||||
|
"/justkitten5.jpg",
|
||||||
|
"/justkitten6.jpg"
|
||||||
|
}
|
||||||
|
local random_pic = math.random(#jk_pics)
|
||||||
|
utilities.send_typing(self, msg.chat.id, 'upload_photo')
|
||||||
|
local file = download_to_file(JK_URL..jk_pics[random_pic])
|
||||||
|
utilities.send_photo(self, msg.chat.id, file)
|
||||||
|
end
|
||||||
|
|
||||||
|
return jk
|
35
miku/plugins/openingsmoe.lua
Normal file
35
miku/plugins/openingsmoe.lua
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
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
|
||||||
|
utilities.send_reply(self, msg, config.errors.connection)
|
||||||
|
return
|
||||||
|
end
|
||||||
|
utilities.send_reply(self, msg, text, 'HTML')
|
||||||
|
end
|
||||||
|
|
||||||
|
return openingsmoe
|
Reference in New Issue
Block a user