]> git.donarmstrong.com Git - infobot.git/commitdiff
On Sun, Feb 23, 2003 at 10:55:55AM -0700, Tim Riker wrote:
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 23 Feb 2003 18:28:03 +0000 (18:28 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 23 Feb 2003 18:28:03 +0000 (18:28 +0000)
> I would like HUP to re-read the chan/user files if the dates have
> changed, and write them if it has not. so you can:
>
> HUP
> edit
> HUP

- now possible.

git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk@769 c11ca15a-4712-0410-83d8-924469b57eb5

blootbot/src/Misc.pl
blootbot/src/core.pl

index 1965db20513723dc3d963982d9ea54325bd110d4..76f11ebe0ad9de7502240a52bed3eccfa9e4db43 100644 (file)
@@ -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.
 ###
index 4c5d0e7e6f23b3efa515197564ee31b26fc0c52b..c82c47e666f4e03d896247ab5038c16531d3cb03 100644 (file)
@@ -493,10 +493,11 @@ sub shutdown {
 
     $ident ||= "blootbot";     # hack.
 
-    if ($sig eq "HUP") {
-       &status("::: not writing user/chan file w/ SIGHUP");
-    } else {
-       &writeUserFile();
+    if (!&isFileUpdated("$bot_state_dir/blootbot.users", $wtime_userfile)) {
+       &writeUserFile()
+    }
+
+    if (!&isFileUpdated("$bot_state_dir/blootbot.chan", $wtime_chanfile)) {
        &writeChanFile();
     }