author | Mikael Berthe <mikael@lilotux.net> |
Thu, 15 Apr 2010 18:57:38 +0200 | |
changeset 16 | 064a50911e05 |
parent 0 | 89add07d6fe4 |
child 66 | d9c00a9fe9d5 |
permissions | -rw-r--r-- |
0 | 1 |
|
2 |
local wtfdbfile = "/home/mikael/.mcabber/lua/mcbot/wtfdb.txt" |
|
3 |
||
16
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
4 |
local wtf = { ["desc"] = "Acronym dictionary" } |
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
5 |
|
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
6 |
function wtf.cmd (args) |
0 | 7 |
local r = {} |
8 |
if not args then return nil, "WTH do you want?" end |
|
9 |
args = args:gsub("[%s%?%.%!]+$", ""):upper() |
|
10 |
for line in io.lines(wtfdbfile) do |
|
11 |
if line:starts(args.."\t") then |
|
12 |
table.insert(r, line) |
|
13 |
end |
|
14 |
end |
|
15 |
local len = table.getn(r) |
|
16 |
if len == 0 then |
|
17 |
return nil, "I don't know, Sir" |
|
18 |
end |
|
19 |
local strresult = r[1] |
|
20 |
for i = 2, len do |
|
21 |
strresult = strresult .. "\n" .. r[i] |
|
22 |
end |
|
23 |
return strresult |
|
24 |
end |
|
25 |
||
26 |
mcbot_register_command("wtf", wtf) |