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

44 lines
1002 B
Lua

do
local function del_mc_color(grr)
grr = string.gsub(grr, '§b', '')
grr = string.gsub(grr, '§l', '')
grr = string.gsub(grr, '§7', '')
grr = string.gsub(grr, '§r', '')
grr = string.gsub(grr, '§2', '')
grr = string.gsub(grr, '§c', '')
return grr
end
local function get_pmc(post)
local url = 'https://api.pegelf.de/mc'
local res,code = https.request(url)
local data = json:decode(res)
if code ~= 200 then return "HTTP-Fehler" end
if not data then return "HTTP-Fehler" end
local title = del_mc_color(data.motd)
local title2 = data.brand
local vers = data.version
local map = data.map
local max_play = data.max_players
local text = unescape(title..'\n'..title2..' ('..vers..')\nWelt: '..map..'\nMax. Spieler: '..max_play..'\n')
return text
end
local function run(msg, matches)
local text = get_pmc(post)
return text
end
return {
description = "Sendet letzten Aka's Blog Beitrag",
usage = "",
patterns = {"^#[Pp][Mm][Cc]$"},
run = run
}
end