]> git.donarmstrong.com Git - infobot.git/commitdiff
- if autoload fails, make poor attempt to load module.
authordms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 21 May 2001 13:11:45 +0000 (13:11 +0000)
committerdms <dms@c11ca15a-4712-0410-83d8-924469b57eb5>
Mon, 21 May 2001 13:11:45 +0000 (13:11 +0000)
- 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

src/Factoids/Question.pl
src/Factoids/Reply.pl
src/IRC/Schedulers.pl
src/Modules/RootWarn.pl
src/modules.pl

index a5ced7be4eccce166a3a756538857a24ffb054c2..fa73b9f80ec849f132c4afd16c0f93d07e8bfc28 100644 (file)
@@ -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.
index 78c13d876be57231c52e292d62f791b76b97d373..dbe933644db5861370640a663796c33110adce9f 100644 (file)
@@ -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;
index 300bf857279442b54ccabe3574236e1a6c15919b..603275051c3d01647e742fc5df7d2e3957cf6d51 100644 (file)
@@ -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();
 
index 1cdae16abe68fbdd14126e2357162d3b85fb4cd1..0cdc6a4502668d136e81b6c0f9e163efd2783d19 100644 (file)
@@ -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.
index 30c5a40c8d9d2d2113ab89e7d0f159ec9bf4e5c4..6aea9e0e2175e88608b7af4d8a14f3ad3e031c93 100644 (file)
@@ -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);
     }
 }