From ac10728090f28a34593da1d125ebf0811d7d9691 Mon Sep 17 00:00:00 2001 From: dmitry kim Date: Fri, 11 Apr 2008 02:30:59 +0400 Subject: * recalculate the relative version timestamp on !version --- bin/rbot | 5 +++-- lib/rbot/core/config.rb | 10 +++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/bin/rbot b/bin/rbot index 37b73e50..7dbff11e 100755 --- 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 diff --git a/lib/rbot/core/config.rb b/lib/rbot/core/config.rb index 1b14ebd8..203cf1de 100644 --- a/lib/rbot/core/config.rb +++ b/lib/rbot/core/config.rb @@ -10,8 +10,16 @@ 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}" } -- cgit v1.2.3