]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
Utils: the array returned by get_first_pars now contains nil for pages where no first...
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 30 Mar 2007 13:39:45 +0000 (13:39 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Fri, 30 Mar 2007 13:39:45 +0000 (13:39 +0000)
lib/rbot/core/utils/utils.rb

index 7856f70a9088af8477e2dacf326149b976000d0d..251e79867bdf7bce427f19db3e2248ba6fa4194f 100644 (file)
@@ -310,12 +310,6 @@ module ::Irc
 
   # miscellaneous useful functions
   module Utils
-    SEC_PER_MIN = 60
-    SEC_PER_HR = SEC_PER_MIN * 60
-    SEC_PER_DAY = SEC_PER_HR * 24
-    SEC_PER_MNTH = SEC_PER_DAY * 30
-    SEC_PER_YR = SEC_PER_MNTH * 12
-
     @@bot = nil unless defined? @@bot
     @@safe_save_dir = nil unless defined?(@@safe_save_dir)
 
@@ -328,6 +322,13 @@ module ::Irc
       @@safe_save_dir = "#{@@bot.botclass}/safe_save"
     end
 
+
+    SEC_PER_MIN = 60
+    SEC_PER_HR = SEC_PER_MIN * 60
+    SEC_PER_DAY = SEC_PER_HR * 24
+    SEC_PER_MNTH = SEC_PER_DAY * 30
+    SEC_PER_YR = SEC_PER_MNTH * 12
+
     def Utils.secs_to_string_case(array, var, string, plural)
       case var
       when 1
@@ -393,6 +394,7 @@ module ::Irc
       File.rename(temp.path, file)
     end
 
+
     def Utils.decode_html_entities(str)
       if $we_have_html_entities_decoder
         return HTMLEntities.decode_entities(str)
@@ -532,7 +534,10 @@ module ::Irc
           # FIXME only do this if the 'url' plugin is loaded
           # TODO even better, put the code here
           # par = @bot.plugins['url'].get_title_from_html(xml)
-          next if par.empty?
+          if par.empty?
+            retval.push(nil)
+            next
+          end
         end
         msg.reply "[#{idx}] #{par}", :overlong => :truncate if msg
         count -=1