]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
* recalculate the relative version timestamp on !version
authordmitry kim <jason@nichego.net>
Thu, 10 Apr 2008 22:30:59 +0000 (02:30 +0400)
committerdmitry kim <jason@nichego.net>
Thu, 10 Apr 2008 22:30:59 +0000 (02:30 +0400)
bin/rbot
lib/rbot/core/config.rb

index 37b73e5088b7d1622e24db38d928a10dd5c3191f..7dbff11e03fe7d7ca4f3fb43c20fb221d24246ca 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -75,8 +75,9 @@ if $version =~ /git/
         branch = $1.dup || "unknown"
         changed = git_out.match(/^# Change(.*)\n/)
         rev = "revision "
-        git_out = `git log -1 --pretty=format:"%h%n%b%n%cr"`.split("\n")
-        rev << git_out.first << ' [' << git_out.last << ']'
+        git_out = `git log -1 --pretty=format:"%h%n%b%n%ct"`.split("\n")
+        rev << git_out.first
+        $version_timestamp = git_out.last.to_i
         if git_out[1].match(/^git-svn-id: \S+@(\d+)/)
           rev << "(svn #{$1})"
         end
index 1b14ebd8cf7adab0ef46958ad4b89f194da4d7ce..203cf1de20faf1e21d87a21b53ada4b01f4d22c7 100644 (file)
 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}"
     }