mcbot/cmds/bofh.lua
author Mikael Berthe <mikael@lilotux.net>
Thu, 15 Apr 2010 21:47:33 +0200
changeset 23 491f7d046353
child 67 5c756a9d7d8c
permissions -rw-r--r--
Add command bofh :-)


local excusefile = "/home/mikael/.mcabber/lua/mcbot/bofh_excuses.txt"

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)