Remove print() in rfc module
authorMikael Berthe <mikael@lilotux.net>
Sun, 18 Apr 2010 21:47:05 +0200
changeset 34 ca01a1696cff
parent 33 50aa4b0d63c1
child 35 1fba2631c743
Remove print() in rfc module
mcbot/cmds/rfc.lua
--- a/mcbot/cmds/rfc.lua	Sun Apr 18 00:05:21 2010 +0200
+++ b/mcbot/cmds/rfc.lua	Sun Apr 18 21:47:05 2010 +0200
@@ -16,10 +16,7 @@
 local function parse_file (fname)
     local fh = io.open(fname)
 
-    if not fh then
-        print("Cannot open RFC database")
-        return 255
-    end
+    if not fh then return nil, "Cannot open RFC database" end
 
     -- Skip header
     local count = 0
@@ -58,6 +55,7 @@
             rfcdb[n] = data
         end
     end
+    return true
 end
 
 local function rfc_lookup_string (rfcstring)
@@ -106,7 +104,10 @@
 function rfc.cmd (rfcnum)
     local empty = true
     for i,v in pairs(rfcdb) do empty = false; break end
-    if empty then parse_file(indexfname) end
+    if empty then
+        local r, err = parse_file(indexfname)
+        if not r then return nil, err end
+    end
 
     if (rfcnum) then
         rfcnum = rfcnum:gsub("^RFC[%s%-]*", "")