From d30940cb5ff75cf7eab81f6a588b3b5297a762ad Mon Sep 17 00:00:00 2001 From: Tom Gilbert Date: Sat, 30 Jul 2005 21:35:57 +0000 Subject: Sat Jul 30 22:33:36 BST 2005 Tom Gilbert * Config items are now objects, various types are available. * The config wizard will now use registered config items if :wizard is set to true for those items. It will ask questions in the order they were registered. * The config module now works for doing runtime configuration. * misc refactoring --- data/rbot/plugins/nickserv.rb | 2 +- data/rbot/plugins/seen.rb | 19 +------------------ data/rbot/plugins/url.rb | 3 ++- 3 files changed, 4 insertions(+), 20 deletions(-) (limited to 'data') diff --git a/data/rbot/plugins/nickserv.rb b/data/rbot/plugins/nickserv.rb index 246f253c..976bb8f8 100644 --- a/data/rbot/plugins/nickserv.rb +++ b/data/rbot/plugins/nickserv.rb @@ -73,7 +73,7 @@ class NickServPlugin < Plugin return unless(m.kind_of? NoticeMessage) if (m.sourcenick == "NickServ" && m.message =~ /This nickname is owned by someone else/) - puts "nickserv asked us to identify for nick #{@bot.nick}" + debug "nickserv asked us to identify for nick #{@bot.nick}" if @registry.has_key?(@bot.nick) @bot.sendmsg "PRIVMSG", "NickServ", "IDENTIFY " + @registry[@bot.nick] end diff --git a/data/rbot/plugins/seen.rb b/data/rbot/plugins/seen.rb index 80d52f65..a8dc1af7 100644 --- a/data/rbot/plugins/seen.rb +++ b/data/rbot/plugins/seen.rb @@ -1,23 +1,6 @@ Saw = Struct.new("Saw", :nick, :time, :type, :where, :message) class SeenPlugin < Plugin - # turn a number of seconds into a human readable string, e.g - # 2 days, 3 hours, 18 minutes, 10 seconds - def secs_to_string(secs) - ret = "" - days = (secs / (60 * 60 * 24)).to_i - secs = secs % (60 * 60 * 24) - hours = (secs / (60 * 60)).to_i - secs = (secs % (60 * 60)) - mins = (secs / 60).to_i - secs = (secs % 60).to_i - ret += "#{days} days, " if days > 0 - ret += "#{hours} hours, " if hours > 0 || days > 0 - ret += "#{mins} minutes and " if mins > 0 || hours > 0 || days > 0 - ret += "#{secs} seconds" - return ret - end - def help(plugin, topic="") "seen => have you seen, or when did you last see " end @@ -80,7 +63,7 @@ class SeenPlugin < Plugin if (ago.to_i == 0) ret += "just now, " else - ret += secs_to_string(ago) + " ago, " + ret += Utils.secs_to_string(ago) + " ago, " end case saw.type diff --git a/data/rbot/plugins/url.rb b/data/rbot/plugins/url.rb index 5629e30a..7972037a 100644 --- a/data/rbot/plugins/url.rb +++ b/data/rbot/plugins/url.rb @@ -1,7 +1,8 @@ Url = Struct.new("Url", :channel, :nick, :time, :url) class UrlPlugin < Plugin - BotConfig.register('url.max_urls', :type => :integer, :default => 100, + BotConfig.register BotConfigIntegerValue.new('url.max_urls', + :default => 100, :validate => Proc.new{|v| v > 0}, :desc => "Maximum number of urls to store. New urls replace oldest ones.") def initialize -- cgit v1.2.3