]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/blobdiff - lib/rbot/core/config.rb
config core botmodule: bolden keys on search
[user/henk/code/ruby/rbot.git] / lib / rbot / core / config.rb
index 1b14ebd8cf7adab0ef46958ad4b89f194da4d7ce..439d7c5104c6cb0a212546ff980b05eeb28c6335 100644 (file)
@@ -4,14 +4,20 @@
 # :title: rbot config management from IRC
 #
 # Author:: Giuseppe "Oblomov" Bilotta <giuseppe.bilotta@gmail.com>
-# Copyright:: (C) 2006,2007 Giuseppe Bilotta
-# License:: GPL v2
 
 class ConfigModule < CoreBotModule
 
   def version_string
-    _("I'm a v. %{version} rubybot%{copyright}%{url}") % {
+    if $version_timestamp.to_i > 0
+      ago = String.new ' ['
+      ago << Utils.secs_to_string(Time.now.to_i - $version_timestamp.to_i)
+      ago << ' ago]'
+    else
+      ago = ''
+    end
+    _("I'm a v. %{version}%{ago} rubybot%{copyright}%{url}") % {
       :version => $version,
+      :ago => ago,
       :copyright => ", #{Irc::Bot::COPYRIGHT_NOTICE}",
       :url => " - #{Irc::Bot::SOURCE_URL}"
     }
@@ -66,13 +72,13 @@ class ConfigModule < CoreBotModule
     rx = Regexp.new(params[:rx].to_s, true)
     cfs = []
     @bot.config.items.each do |k, v|
-      cfs << v if k.to_s.match(rx) or (v.desc.match(rx) rescue false)
+      cfs << [Bold + k.to_s + Bold, v.desc] if k.to_s.match(rx) or (v.desc.match(rx) rescue false)
     end
     if cfs.empty?
       m.reply _("no config key found matching %{r}") % { :r => params[:rx].to_s}
     else
-      m.reply _("possible keys: %{kl}") % { :kl => cfs.map { |c| c.key}.join(', ') }
-      m.reply cfs.map { |c| [c.key, c.desc].join(': ') }.join("\n")
+      m.reply _("possible keys: %{kl}") % { :kl => cfs.map { |c| c.first}.join(', ') }
+      m.reply cfs.map { |c| c.join(': ') }.join("\n")
     end
   end
 
@@ -197,10 +203,8 @@ class ConfigModule < CoreBotModule
     case m.ctcp.intern
     when :VERSION
       m.ctcp_reply version_string
-      @bot.irclog "@ #{m.source} asked #{who} about version info"
     when :SOURCE
       m.ctcp_reply Irc::Bot::SOURCE_URL
-      @bot.irclog "@ #{m.source} asked #{who} about source info"
     end
   end