mcbot/cmds/bofh.lua
author Mikael Berthe <mikael@lilotux.net>
Wed, 21 Oct 2015 19:10:04 +0200
changeset 73 2ca07b5226c1
parent 67 5c756a9d7d8c
permissions -rw-r--r--
Update wtfdb


local home = os.getenv("HOME")
local excusefile = home.."/.mcabber/mcabbot/mcbot/bofh_excuses.txt"
home = nil

local bofh = { ["desc"] = "Give a BOFH excuse",
               ["aliases"] = { "excuse" } }

function bofh.cmd (args, botdata, cmd)
    local r = {}
    if cmd:lower() == "excuse" and args and not args:match("[!%?]+") then
        return nil
    end
    for line in io.lines(excusefile) do table.insert(r, line) end
    local len = table.getn(r)
    if len == 0 then
        return nil, "I have no excuse, Sir...  :-("
    end
    local n = math.random(len)
    return "BOFH's excuse: "..r[n]
end

mcbot_register_command("bofh", bofh)