author | Mikael Berthe <mikael@lilotux.net> |
Tue, 27 Nov 2012 16:36:17 +0100 | |
changeset 67 | 5c756a9d7d8c |
parent 66 | d9c00a9fe9d5 |
permissions | -rw-r--r-- |
66
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
1 |
|
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
2 |
-- This module is part of the McBot / mcabbot project |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
3 |
-- What-The-F... module. |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
4 |
-- |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
5 |
-- Copyright (C) 2010-2012 Mikael Berthe <mikael@lilotux.net> |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
6 |
-- |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
7 |
-- This program is free software; you can redistribute it and/or modify |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
8 |
-- it under the terms of the GNU General Public License as published by |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
9 |
-- the Free Software Foundation; either version 2 of the License, or (at |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
10 |
-- your option) any later version. |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
11 |
-- |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
12 |
-- Please check the license in the COPYING file at the root of the tree. |
d9c00a9fe9d5
Add notices before public release
Mikael Berthe <mikael@lilotux.net>
parents:
16
diff
changeset
|
13 |
-- |
0 | 14 |
|
67
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
66
diff
changeset
|
15 |
local home = os.getenv("HOME") |
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
66
diff
changeset
|
16 |
local wtfdbfile = home.."/.mcabber/mcabbot/mcbot/wtfdb.txt" |
5c756a9d7d8c
Quick'n dirty hack to remove hardcoded paths
Mikael Berthe <mikael@lilotux.net>
parents:
66
diff
changeset
|
17 |
home = nil |
0 | 18 |
|
16
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
19 |
local wtf = { ["desc"] = "Acronym dictionary" } |
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
20 |
|
064a50911e05
Update command infrastructure
Mikael Berthe <mikael@lilotux.net>
parents:
0
diff
changeset
|
21 |
function wtf.cmd (args) |
0 | 22 |
local r = {} |
23 |
if not args then return nil, "WTH do you want?" end |
|
24 |
args = args:gsub("[%s%?%.%!]+$", ""):upper() |
|
25 |
for line in io.lines(wtfdbfile) do |
|
26 |
if line:starts(args.."\t") then |
|
27 |
table.insert(r, line) |
|
28 |
end |
|
29 |
end |
|
30 |
local len = table.getn(r) |
|
31 |
if len == 0 then |
|
32 |
return nil, "I don't know, Sir" |
|
33 |
end |
|
34 |
local strresult = r[1] |
|
35 |
for i = 2, len do |
|
36 |
strresult = strresult .. "\n" .. r[i] |
|
37 |
end |
|
38 |
return strresult |
|
39 |
end |
|
40 |
||
41 |
mcbot_register_command("wtf", wtf) |