mcbot/cmds/wtf.lua
changeset 0 89add07d6fe4
child 16 064a50911e05
equal deleted inserted replaced
-1:000000000000 0:89add07d6fe4
       
     1 
       
     2 local wtfdbfile = "/home/mikael/.mcabber/lua/mcbot/wtfdb.txt"
       
     3 
       
     4 local function wtf (args)
       
     5     local r = {}
       
     6     if not args then return nil, "WTH do you want?" end
       
     7     args = args:gsub("[%s%?%.%!]+$", ""):upper()
       
     8     for line in io.lines(wtfdbfile) do
       
     9         if line:starts(args.."\t") then
       
    10             table.insert(r, line)
       
    11         end
       
    12     end
       
    13     local len = table.getn(r)
       
    14     if len == 0 then
       
    15         return nil, "I don't know, Sir"
       
    16     end
       
    17     local strresult = r[1]
       
    18     for i = 2, len do
       
    19         strresult = strresult .. "\n" .. r[i]
       
    20     end
       
    21     return strresult
       
    22 end
       
    23 
       
    24 mcbot_register_command("wtf", wtf)