git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@630
c11ca15a-4712-0410-83d8-
924469b57eb5
my($reply,$flag) = @_;
# $date, $time.
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+//;
$date =~ s/\:\d+(\s+\w+)\s+\d+$/$1/;
$reply =~ s/\$date/$date/gi;
$date =~ s/\w+\s+\w+\s+\d+\s+//;
$reply =~ s/\$time/$date/gi;
# dollar variables.
$reply =~ s/\$time/$date/gi;
# dollar variables.
- ### TODO: number of digits. 'x.y'
- # too hard.
if ($reply =~ /\$rand(\d+)(\.(\d+))?/) {
my $max = $1;
my $dot = $3 || 0;
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);
+ #&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/) {
}
$reply =~ s/\$ident/$ident/g;
if ($reply =~ /\$startTime/) {
- my $time = scalar(localtime $^T);
+ my $time = scalar(gmtime $^T);
$reply =~ s/\$startTime/$time/;
}
$reply =~ s/\$startTime/$time/;
}
}
if ($reply =~ /\$factoids/) {
}
if ($reply =~ /\$factoids/) {
- my $count = &countKeys("factoids");
+ my $factoids = &countKeys("factoids");
$reply =~ s/\$factoids/$factoids/;
}
$reply =~ s/\$factoids/$factoids/;
}