]> git.donarmstrong.com Git - infobot.git/blobdiff - src/Misc.pl
ws
[infobot.git] / src / Misc.pl
index 04ace3f0c307e6669a03302a1a32f8af0e3e829b..3163bb3201690e9970d289305af6e4929806326b 100644 (file)
@@ -96,7 +96,7 @@ sub timeget {
     } else {                   # the real thing.
        return [gettimeofday()];
     }
-}    
+}
 
 sub timedelta {
     my($start_time) = shift;
@@ -470,6 +470,22 @@ sub isStale {
     return 0;
 }
 
+sub isFileUpdated {
+    my ($file, $time) = @_;
+
+    if (! -f $file) {
+       return 1;
+    }
+
+    my $time_file = (stat $file)[9];
+
+    if ($time == $time_file) {
+       return 0;
+    } else {
+       return 1;
+    }
+}
+
 ##########
 ### make commands.
 ###
@@ -644,22 +660,13 @@ sub closeStats {
 
        $i      += $cmdstats{$type};
 
-       my %hash = (
-               nick => $type,
-               type => "cmdstats",
-               counter => $i
-       );              
-       $hash{time} = time() if ($z);
 
-       if (0) {
-           &sqlReplace("stats", %hash);
-       } else {
-           &sqlReplace("stats", {
-               nick            => $type,
-               type            => "cmdstats",
-               -counter        => "counter+1",
-           } );
-       }
+       &sqlReplace("stats", {
+           nick        => $type,
+           type        => "cmdstats",
+           'time'      => time(),
+           counter     => $i,
+       } );
     }
 }