summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-30 13:39:45 +0000
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2007-03-30 13:39:45 +0000
commit4acb228dfdff2ffb2d76f87d216775b7874b5df6 (patch)
treee42bda2a556aede028672cf0815fa423f6b3144c /lib
parentc56db0e3b6269a0cae8e93cafb158a0d3f3c8a2c (diff)
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
Diffstat (limited to 'lib')
-rw-r--r--lib/rbot/core/utils/utils.rb19
1 files changed, 12 insertions, 7 deletions
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