From: dms Date: Mon, 21 May 2001 13:11:45 +0000 (+0000) Subject: - if autoload fails, make poor attempt to load module. X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=1b18dcfaff9e5faa0ab252d0459509f843c0c435;p=infobot.git - if autoload fails, make poor attempt to load module. - modified Question() to use substVars() - added hack for "me => $who" - don't do factoidDeleteDelay if stale is invalid. - fixed typo in rootWarn. git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@493 c11ca15a-4712-0410-83d8-924469b57eb5 --- diff --git a/src/Factoids/Question.pl b/src/Factoids/Question.pl index a5ced7b..fa73b9f 100644 --- a/src/Factoids/Question.pl +++ b/src/Factoids/Question.pl @@ -195,6 +195,8 @@ sub factoidArgs { next unless (@vals); + &DEBUG("vals => @vals"); + &status("Question: factoid Arguments for '$str'"); # todo: use getReply() - need to modify it :( my $i = 0; @@ -203,18 +205,29 @@ sub factoidArgs { foreach ( split(',', $1) ) { my $val = $vals[$i]; + &DEBUG("val => $val"); if (!defined $val) { &status("factArgs: vals[$i] == undef; not SARing '$_' for '$str'"); next; } - if ($result = &substVars($result)) { - # hrm... - } else { + my $done = 0; + my $old = $result; + while (1) { + $result = &substVars($result,1); + last if ($old eq $result); + $old = $result; + $done++; + } + + # hack. + $vals[$i] =~ s/^me$/$who/gi; + + if (!$done) { &status("factArgs: SARing '$_' to '$vals[$i]'."); $result =~ s/\Q$_\E/$vals[$i]/; - $i++; } + $i++; } # nasty hack to get partial &getReply() functionality. diff --git a/src/Factoids/Reply.pl b/src/Factoids/Reply.pl index 78c13d8..dbe9336 100644 --- a/src/Factoids/Reply.pl +++ b/src/Factoids/Reply.pl @@ -243,7 +243,7 @@ sub SARit { } sub substVars { - my($reply) = @_; + my($reply,$flag) = @_; # $date, $time. my $date = scalar(localtime()); @@ -253,8 +253,11 @@ sub substVars { $reply =~ s/\$time/$date/gi; # dollar variables. - $reply =~ s/\$nick/$who/g; - $reply =~ s/\$who/$who/g; # backward compat. + if ($flag) { + $reply =~ s/\$nick/$who/g; + $reply =~ s/\$who/$who/g; # backward compat. + } + if ($reply =~ /\$(user(name)?|host)/) { my ($username, $hostname) = split /\@/, $uh; $reply =~ s/\$user(name)?/$username/g; diff --git a/src/IRC/Schedulers.pl b/src/IRC/Schedulers.pl index 300bf85..6032750 100644 --- a/src/IRC/Schedulers.pl +++ b/src/IRC/Schedulers.pl @@ -1047,6 +1047,11 @@ sub factoidCheck { my @list = &searchTable("factoids", "factoid_key", "factoid_key", " #DEL#"); my $stale = &getChanConfDefault("factoidDeleteDelay", 30) *60*60*24; + if ($stale < 1) { + # disable it since it's "illegal". + return; + } + &DEBUG("stale => $stale"); my $time = time(); diff --git a/src/Modules/RootWarn.pl b/src/Modules/RootWarn.pl index 1cdae16..0cdc6a4 100644 --- a/src/Modules/RootWarn.pl +++ b/src/Modules/RootWarn.pl @@ -5,11 +5,11 @@ # Created: 19991008 # -use strict; +### use strict; sub rootWarn { my ($nick,$user,$host,$chan) = @_; - my $attempt = &dbGet("rootwarn", "attempt", "nick='.lc($nick)."'") || 0; + my $attempt = &dbGet("rootwarn", "attempt", "nick='".lc($nick)."'") || 0; my $warnmode = &getChanConf("rootWarnMode"); if ($attempt == 0) { # first timer. diff --git a/src/modules.pl b/src/modules.pl index 30c5a40..6aea9e0 100644 --- a/src/modules.pl +++ b/src/modules.pl @@ -369,10 +369,15 @@ if ($@) { sub AUTOLOAD { return if ($AUTOLOAD =~ /__/); # internal. - &ERROR("UNKNOWN FUNCTION CALLED: $AUTOLOAD"); - foreach (@_) { - next unless (defined $_); - &status(" => $_"); + my $str = join(', ', @_); + &ERROR("UNKNOWN FUNCTION CALLED: $AUTOLOAD ($str)"); + + $AUTOLOAD =~ s/^(\S+):://g; + + if (exists $myModules{lc $AUTOLOAD}) { + # hopefully this will work. + &DEBUG("Trying to load module $AUTOLOAD..."); + &loadMyModule(lc $AUTOLOAD); } }