mcbot/cmds/bofh.lua
changeset 23 491f7d046353
child 67 5c756a9d7d8c
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mcbot/cmds/bofh.lua	Thu Apr 15 21:47:33 2010 +0200
@@ -0,0 +1,21 @@
+
+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)