]> git.donarmstrong.com Git - infobot.git/commitdiff
Second round of News changes and bug fixes, kudos to greycat
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 1 Apr 2001 15:00:05 +0000 (15:00 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 1 Apr 2001 15:00:05 +0000 (15:00 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@423 c11ca15a-4712-0410-83d8-924469b57eb5

src/IRC/IrcHooks.pl
src/Misc.pl

index 87d3f6857967ff88098b3d4a7172ed48e98c167f..0fce62ed03aa2c61cb1d2f38daa1e9e535b6954c 100644 (file)
@@ -491,7 +491,7 @@ sub on_join {
        if (scalar @new) {
            &msg($who, "+==== New news for $chan (".scalar(@new)."):");
            # todo: show how many sec/min/etc ago?
-           my $timestr = &Time2String( $::newsuser{$chan}{$who} );
+           my $timestr = &Time2String( time() - $::newsuser{$chan}{$who} );
            &msg($who, "|= Last time read $timestr ago");
 
            foreach (@new) {
@@ -500,6 +500,7 @@ sub on_join {
                &msg($who, sprintf("\002[\002%2d\002]\002 %s (%s)",
                        $i, $_, &Time2String($age) ) );
            }
+           &msg($who, "to read, do 'news read <#>' or 'news read <keyword>'");
 
            # lame hack to prevent dupes if we just ignore it.
            $::newsuser{$chan}{$who} = time();
index b9c473fc9dc704446038105bc5ef5a84495657f8..1a216c6ce88284a15c2449a4fea43b9b6c967ec2 100644 (file)
@@ -167,8 +167,13 @@ sub Time2String {
     my $time = shift;
     my $retval;
 
-    return("0s")
-               if (!defined $time or $time !~ /\d+/ or $time <= 0);
+    return("NULL s") if (!defined $time or $time !~ /\d+/);
+
+    my $prefix = "";
+    if ($time < 0) {
+       $time = - $time;
+       $prefix = "- ";
+    }
 
     my $s = int($time) % 60;
     my $m = int($time / 60) % 60;
@@ -180,7 +185,7 @@ sub Time2String {
     $retval .= sprintf(" \002%d\002m", $m) if ($m != 0);
     $retval .= sprintf(" \002%d\002s", $s) if ($s != 0);
 
-    return substr($retval, 1);
+    return $prefix.substr($retval, 1);
 }
 
 ###