author | Mikael Berthe <mikael@lilotux.net> |
Tue, 27 Nov 2012 16:36:17 +0100 | |
changeset 67 | 5c756a9d7d8c |
parent 23 | 491f7d046353 |
permissions | -rw-r--r-- |
23 | 1 |
|
67
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
2 |
local home = os.getenv("HOME") |
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
3 |
local excusefile = home.."/.mcabber/mcabbot/mcbot/bofh_excuses.txt" |
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
23
diff
changeset
|
4 |
home = nil |
23 | 5 |
|
6 |
local bofh = { ["desc"] = "Give a BOFH excuse", |
|
7 |
["aliases"] = { "excuse" } } |
|
8 |
||
9 |
function bofh.cmd (args, botdata, cmd) |
|
10 |
local r = {} |
|
11 |
if cmd:lower() == "excuse" and args and not args:match("[!%?]+") then |
|
12 |
return nil |
|
13 |
end |
|
14 |
for line in io.lines(excusefile) do table.insert(r, line) end |
|
15 |
local len = table.getn(r) |
|
16 |
if len == 0 then |
|
17 |
return nil, "I have no excuse, Sir... :-(" |
|
18 |
end |
|
19 |
local n = math.random(len) |
|
20 |
return "BOFH's excuse: "..r[n] |
|
21 |
end |
|
22 |
||
23 |
mcbot_register_command("bofh", bofh) |