mcbot/cmds/wtf.lua
changeset 0 89add07d6fe4
child 16 064a50911e05
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mcbot/cmds/wtf.lua	Sun Apr 11 18:13:18 2010 +0200
@@ -0,0 +1,24 @@
+
+local wtfdbfile = "/home/mikael/.mcabber/lua/mcbot/wtfdb.txt"
+
+local function wtf (args)
+    local r = {}
+    if not args then return nil, "WTH do you want?" end
+    args = args:gsub("[%s%?%.%!]+$", ""):upper()
+    for line in io.lines(wtfdbfile) do
+        if line:starts(args.."\t") then
+            table.insert(r, line)
+        end
+    end
+    local len = table.getn(r)
+    if len == 0 then
+        return nil, "I don't know, Sir"
+    end
+    local strresult = r[1]
+    for i = 2, len do
+        strresult = strresult .. "\n" .. r[i]
+    end
+    return strresult
+end
+
+mcbot_register_command("wtf", wtf)