23
|
1 |
|
|
2 |
local excusefile = "/home/mikael/.mcabber/lua/mcbot/bofh_excuses.txt" |
|
3 |
|
|
4 |
local bofh = { ["desc"] = "Give a BOFH excuse", |
|
5 |
["aliases"] = { "excuse" } } |
|
6 |
|
|
7 |
function bofh.cmd (args, botdata, cmd) |
|
8 |
local r = {} |
|
9 |
if cmd:lower() == "excuse" and args and not args:match("[!%?]+") then |
|
10 |
return nil |
|
11 |
end |
|
12 |
for line in io.lines(excusefile) do table.insert(r, line) end |
|
13 |
local len = table.getn(r) |
|
14 |
if len == 0 then |
|
15 |
return nil, "I have no excuse, Sir... :-(" |
|
16 |
end |
|
17 |
local n = math.random(len) |
|
18 |
return "BOFH's excuse: "..r[n] |
|
19 |
end |
|
20 |
|
|
21 |
mcbot_register_command("bofh", bofh) |