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

39 lines
1.0 KiB
Lua
Raw Normal View History

2015-04-29 21:57:38 +02:00
function getAnime(query)
local api = "http://ajax.googleapis.com/ajax/services/search/web?v=1.0&safe=active&hl=de&q=site%3Amyanimelist.net"
2015-04-29 21:57:38 +02:00
local parameters = "+".. (URL.escape(query) or "")
-- Do the request
local res, code = https.request(api..parameters)
if code ~=200 then return nil end
local data = json:decode(res)
local results={}
for key,result in ipairs(data.responseData.results) do
table.insert(results, {
result.titleNoFormatting,
result.unescapedUrl or result.url
})
end
return results
end
function stringlinks(results)
local stringresults=""
for key,val in ipairs(results) do
stringresults=stringresults..val[1].." - "..val[2].."\n"
end
return stringresults
end
function run(msg, matches)
local results = getAnime(matches[1])
return stringlinks(results)
end
return {
description = "",
usage = {"/myanimelist [Anime]","/mal [Anime]"},
patterns = {"^/myanimelist (.*)$","^/mal (.*)$"},
run = run
2015-05-22 17:01:33 +02:00
}
--Modified by Akamaru [https://ponywave.de]