From: Giuseppe Bilotta Date: Fri, 30 Mar 2007 13:39:45 +0000 (+0000) Subject: Utils: the array returned by get_first_pars now contains nil for pages where no first... X-Git-Url: https://git.netwichtig.de/gitweb/?a=commitdiff_plain;ds=sidebyside;h=4acb228dfdff2ffb2d76f87d216775b7874b5df6;p=user%2Fhenk%2Fcode%2Fruby%2Frbot.git Utils: the array returned by get_first_pars now contains nil for pages where no first par was found. Also rearrange some code to keep relevant code together --- diff --git a/lib/rbot/core/utils/utils.rb b/lib/rbot/core/utils/utils.rb index 7856f70a..251e7986 100644 --- a/lib/rbot/core/utils/utils.rb +++ b/lib/rbot/core/utils/utils.rb @@ -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