- 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@493
c11ca15a-4712-0410-83d8-
924469b57eb5
next unless (@vals);
+ &DEBUG("vals => @vals");
+
&status("Question: factoid Arguments for '$str'");
# todo: use getReply() - need to modify it :(
my $i = 0;
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.
}
sub substVars {
- my($reply) = @_;
+ my($reply,$flag) = @_;
# $date, $time.
my $date = scalar(localtime());
$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;
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();
# 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.
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);
}
}