]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Factoids/Reply.pl
If topicAuthor is on then show it in topic, otherwise just topic -- contribution...
[infobot.git] / src / Factoids / Reply.pl
index aedf3cbdb12eeb9c995b7dc694402e8ac1704b74..fb69ebffed122dbe3f0c020bf3e1ae44fa732101 100644 (file)
@@ -11,6 +11,7 @@
 ##
 
 # use strict;  # TODO
+use POSIX qw(strftime);
 
 use vars qw($msgType $uh $lastWho $ident);
 use vars qw(%lang %lastWho);
@@ -80,7 +81,7 @@ sub getReply {
        ### FLOOD REPETION AND PROTECTION. -20000124
 
        # stats code.
-       ### FIXME: old mysql doesn't support
+       ### FIXME: old mysql/sqlite doesn't support
        ### "requested_count=requested_count+1".
        $count++;
        &sqlSet("factoids", {'factoid_key' => $factoid}, {
@@ -149,11 +150,11 @@ sub getReply {
     ###
 
     # don't evaluate if it has factoid arguments.
-    if ($message =~ /^cmd:/i) {
-       &status("Reply: not doing substVars (eval dollar vars)");
-    } else {
+#    if ($message =~ /^cmd:/i) {
+#      &status("Reply: not doing substVars (eval dollar vars)");
+#    } else {
        $reply = &substVars($reply,1);
-    }
+#    }
 
     $reply;
 }
@@ -268,13 +269,17 @@ sub SARit {
 sub substVars {
     my($reply,$flag) = @_;
 
-    # $date, $time.
+    # $date, $time, $day.
     # TODO: support localtime.
-    my $date   =  scalar(gmtime());
-    $date      =~ s/\:\d+(\s+\w+)\s+\d+$/$1/;
+    my $date   =  strftime("%Y.%m.%d", gmtime());
     $reply     =~ s/\$date/$date/gi;
-    $date      =~ s/\w+\s+\w+\s+\d+\s+//;
-    $reply     =~ s/\$time/$date/gi;
+    my $time   =  strftime("%k:%M:%S", gmtime());
+    $reply     =~ s/\$time/$time/gi;
+    my $day    =  strftime("%A", gmtime());
+    $reply     =~ s/\$day/$day/gi;
+
+    # support $ident when I have multiple nicks
+    my $mynick = $conn->nick() if $conn;
 
     # dollar variables.
     if ($flag) {
@@ -319,7 +324,7 @@ sub substVars {
        }
     }
 
-    $reply     =~ s/\$ident/$ident/g;
+    $reply     =~ s/\$ident/$mynick/g;
 
     if ($reply =~ /\$startTime/) {
        my $time = scalar(gmtime $^T);