- 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
# 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;
sub chanServCheck {
($chan) = @_;
- if (!defined $chan or $chan =~ /^$/) {
+ if (!defined $chan or $chan =~ /^\s*$/) {
&WARN("chanServCheck: chan == NULL.");
return 0;
}
&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");
&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;
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";
&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";
if ($age < $moduleAge{$file}) {
&WARN("rM: we're not gonna downgrade '$file'; use touch.");
+ &DEBUG("age => $age");
+ &DEBUG("mA{$file} => $moduleAge{$file}");
return;
}