]> git.donarmstrong.com Git - infobot.git/commitdiff
fix rand, factoids, convert to gmtime
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 20 Nov 2002 01:46:34 +0000 (01:46 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Wed, 20 Nov 2002 01:46:34 +0000 (01:46 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@630 c11ca15a-4712-0410-83d8-924469b57eb5

src/Factoids/Reply.pl

index 575e1b34143e7bb59e38c1f28530510e918d261e..58ebb0f53ec37fc1470975b8cbebae54e1b79387 100644 (file)
@@ -250,11 +250,11 @@ sub substVars {
     my($reply,$flag) = @_;
 
     # $date, $time.
-    my $date   =  scalar(localtime());
+    # todo: support localtime.
+    my $date   =  scalar(gmtime());
     $date      =~ s/\:\d+(\s+\w+)\s+\d+$/$1/;
     $reply     =~ s/\$date/$date/gi;
     $date      =~ s/\w+\s+\w+\s+\d+\s+//;
-    # todo: support UTC.
     $reply     =~ s/\$time/$date/gi;
 
     # dollar variables.
@@ -286,28 +286,24 @@ sub substVars {
        }
 
        # eg: $rand100.3
-       ### TODO: number of digits. 'x.y'
-       # too hard.
        if ($reply =~ /\$rand(\d+)(\.(\d+))?/) {
            my $max = $1;
            my $dot = $3 || 0;
-           &status("dot => $dot, max => $max, rand=>$rand");
-           $rand = sprintf("%.*f", $dot, $rand*$max);
            my $orig = $&;
+           #&DEBUG("dot => $dot, max => $max, rand=>$rand");
+           $rand = sprintf("%.*f", $dot, $rand*$max);
 
-           &status("swapping $orig to $rand");
-           &status("reply => $reply");
-           $reply =~ s/$orig/$rand/eg;
-           &status("reply => $reply");
+           &DEBUG("swapping $orig to $rand");
+           $reply =~ s/\Q$orig\E/$rand/eg;
+       } else {
+           $reply =~ s/\$rand/$rand/g;
        }
-
-       $reply =~ s/\$rand/$rand/g;
     }
 
     $reply     =~ s/\$ident/$ident/g;
 
     if ($reply =~ /\$startTime/) {
-       my $time = scalar(localtime $^T);
+       my $time = scalar(gmtime $^T);
        $reply =~ s/\$startTime/$time/;
     }
 
@@ -317,7 +313,7 @@ sub substVars {
     }
 
     if ($reply =~ /\$factoids/) {
-       my $count = &countKeys("factoids");
+       my $factoids = &countKeys("factoids");
        $reply =~ s/\$factoids/$factoids/;
     }