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_user.lua
2016-06-22 13:59:06 +02:00

40 lines
1.6 KiB
Lua

do
local function get_user_info(name)
local url = 'https://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20xml%20where%20url%3D%22http%3A%2F%2Fmyanimelist.net%2Fmalappinfo.php%3Fu%3D'..name..'%22&format=json&diagnostics=true&callback='
local res,code = http.request(url)
local data = json:decode(res).query.results.myanimelist.myinfo
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local name = data.user_name
local watching = data.user_watching
local pause = data.user_onhold
local dropped = data.user_dropped
local complete = data.user_completed
local planed = data.user_plantowatch
--local totaldays = data.user_days_spent_watching --What is this?
local mal_url = 'http://myanimelist.net/profile/'..data.user_name
--local text = name..' schaut derzeit '..watching..' Animes, hat '..pause..' pausiert, '..dropped..' abgebrochen und '..complete..' beendet. '..planed..' stehen auf der Watchlist.\n'..name..' hat '..totaldays..' Tage damit verbracht Animes zu schauen.\n'..mal_url
local text = name..' schaut derzeit '..watching..' Animes, hat '..pause..' pausiert, '..dropped..' abgebrochen und '..complete..' beendet. '..planed..' stehen auf der Watchlist.\n'..mal_url
return text
end
local function run(msg, matches)
local name = matches[1]
local text = get_user_info(name)
local receiver = get_receiver(msg)
return text
end
return {
description = "Sendet Infos zu einem MAL-User.",
usage = "#malu [Name]: Sendet Infos zum User",
patterns = {"^#malu (.+)$",
"myanimelist.net/profile/(.*)$"
},
run = run
}
end