local wiimmfi = {}
local http = require('socket.http')
local utilities = require('otouto.utilities')
local bindings = require('otouto.bindings')
function wiimmfi:init(config)
wiimmfi.triggers = {
"^/(mkw)$",
"^/wiimmfi$",
"^/wfc$"
}
wiimmfi.doc = [[*
]]..config.cmd_pat..[[wfc*: Zeigt alle Wiimmfi-Spieler an
*]]..config.cmd_pat..[[mkw*: Zeigt alle Mario-Kart-Wii-Spieler an]]
end
wiimmfi.command = 'wfc, /mkw'
function wiimmfi:getplayer(game)
local url = 'http://wiimmfi.de/game'
local res,code = http.request(url)
if code ~= 200 then return "Fehler beim Abrufen von wiimmfi.de" end
if game == 'mkw' then
local players = string.match(res, "
(.-)")
if players == nil then players = 0 end
text = 'Es spielen gerade '..players..' Spieler Mario Kart Wii'
else
local players = string.match(res, " | (.-) | .-", ": ")
local players = string.gsub(players, " | ", "")
local players = string.gsub(players, "Wii", "")
local players = string.gsub(players, "WiiWare", "")
local players = string.gsub(players, "NDS", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
local players = string.gsub(players, "", "")
if players == nil then players = 'Momentan spielt keiner auf Wiimmfi :(' end
text = players
end
return text
end
function wiimmfi:action(msg, config, matches)
if matches[1] == "mkw" then
utilities.send_reply(self, msg, wiimmfi:getplayer('mkw'))
return
else
utilities.send_reply(self, msg, wiimmfi:getplayer())
return
end
end
return wiimmfi