]> git.donarmstrong.com Git - infobot.git/commitdiff
- modules: age of a few files were set to time(); use stat. Fixed.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 6 Jan 2002 13:49:58 +0000 (13:49 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Sun, 6 Jan 2002 13:49:58 +0000 (13:49 +0000)
- validChan: check for undefine arg; check for $c{$c} to avoid creating it.
- chanservCheck: check for $c{$c} to avoid creating it.
- factoidCheck: now deferred.

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

src/IRC/Irc.pl
src/IRC/IrcHelpers.pl
src/IRC/Schedulers.pl
src/modules.pl

index e8a3a9243534cac1ebd6f15533103f43df038286..6b35bcae2247e4eba49782fe053f7f17758e2525 100644 (file)
@@ -717,14 +717,20 @@ sub IsNickInAnyChan {
 
 # Usage: &validChan($chan);
 sub validChan {
+    # todo: use $c instead?
     my ($chan) = @_;
 
+    if (!defined $chan or $chan =~ /^\s*$/) {
+       return 0;
+    }
+
     if (lc $chan ne $chan) {
        &WARN("validChan: lc chan != chan. ($chan); fixing.");
        $chan =~ tr/A-Z/a-z/;
     }
 
-    if (exists $channels{$chan}) {
+    # it's possible that this check creates the hash if empty.
+    if (defined $channels{$chan} or exists $channels{$chan}) {
        if ($chan eq "_default") {
 #          &WARN("validC: chan cannot be _default! returning 0!");
            return 0;
index 0bc344d982fe048e7ccc5e127f5c9197d944b1f2..2ce1acb91259eefee97eb714fd6b1511ee6b5ae9 100644 (file)
@@ -321,7 +321,7 @@ sub chanLimitVerify {
 sub chanServCheck {
     ($chan) = @_;
 
-    if (!defined $chan or $chan =~ /^$/) {
+    if (!defined $chan or $chan =~ /^\s*$/) {
        &WARN("chanServCheck: chan == NULL.");
        return 0;
     }
@@ -341,7 +341,11 @@ sub chanServCheck {
        &rawout("WHO NickServ");
        return 0;
     }
-    return 0 if (exists $channels{$chan}{'o'}{$ident});
+    # check for first hash then for next hash.
+    # todo: a function for &ischanop()? &isvoice()?
+    if (exists $channels{$chan} and exists $channels{$chan}{'o'}{$ident}) {
+       return 0;
+    }
 
     &status("ChanServ ==> Requesting ops for $chan. (chanServCheck)");
     &rawout("PRIVMSG ChanServ :OP $chan $ident");
index 2077d48a7765766bc9aebffe571c5a77c4ec715d..54ada62038330fb9b4bbfed340b52ea7d0fb194c 100644 (file)
@@ -37,7 +37,7 @@ sub setupSchedulers {
     &freshmeatLoop(2);
     &kernelLoop(2);
     &wingateWriteFile(2);
-    &factoidCheck(1);
+    &factoidCheck(2);  # takes a couple of seconds on a 486. defer it
     &newsFlush(1);
 
 #    my $count = map { exists $sched{$_}{TIME} } keys %sched;
index c567c2e585ffe74dcbe47e9c8df7ef7ca64f2114..bea0f2e0f663ac6ab89abd4a7485de77ffb68f13 100644 (file)
@@ -76,7 +76,8 @@ sub loadCoreModules {
 sub loadDBModules {
     &status("Loading DB modules...");
 
-    $moduleAge{"$bot_src_dir/modules.pl"} = time();
+    my $f = "$bot_src_dir/modules.pl";
+    $moduleAge{$f} = (stat $f)[9];
 
     if ($param{'DBType'} =~ /^mysql$/i) {
        eval "use DBI";
@@ -87,8 +88,9 @@ sub loadDBModules {
        &showProc(" (DBI // mysql)");
 
        &status("  using MySQL support.");
-       require "$bot_src_dir/db_mysql.pl";
-       $moduleAge{"$bot_src_dir/db_mysql.pl"} = time();
+       $f = "$bot_src_dir/db_mysql.pl";
+       require $f;
+       $moduleAge{$f} = (stat $f)[9];
 
     } elsif ($param{'DBType'} =~ /^pgsql$/i) {
 #      eval "use Pg";
@@ -248,6 +250,8 @@ sub reloadModule {
 
        if ($age < $moduleAge{$file}) {
            &WARN("rM: we're not gonna downgrade '$file'; use touch.");
+           &DEBUG("age => $age");
+           &DEBUG("mA{$file} => $moduleAge{$file}");
            return;
        }