mcbot/cmds/bofh.lua
author Mikael Berthe <mikael@lilotux.net>
Tue, 27 Nov 2012 16:36:17 +0100
changeset 67 5c756a9d7d8c
parent 23 491f7d046353
permissions -rw-r--r--
Quick'n dirty hack to remove hardcoded paths


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)