]> git.donarmstrong.com Git - infobot.git/commitdiff
really support negative booleans and and return -1 for IsChanConf() when they are...
authortimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 6 Jan 2006 08:36:43 +0000 (08:36 +0000)
committertimriker <timriker@c11ca15a-4712-0410-83d8-924469b57eb5>
Fri, 6 Jan 2006 08:36:43 +0000 (08:36 +0000)
git-svn-id: https://svn.code.sf.net/p/infobot/code/trunk/blootbot@1250 c11ca15a-4712-0410-83d8-924469b57eb5

14 files changed:
TODO
files/sample/blootbot.chan
src/DynaConfig.pl
src/Factoids/Core.pl
src/Factoids/Question.pl
src/Factoids/Update.pl
src/IRC/Irc.pl
src/IRC/IrcHelpers.pl
src/IRC/IrcHooks.pl
src/IRC/Schedulers.pl
src/Misc.pl
src/Modules/News.pl
src/core.pl
src/modules.pl

diff --git a/TODO b/TODO
index 133a4535a76c9096d4ed57e6a1989b6c5c88f7ac..b3ddccc00a3e4b710a005a3c1b91d84e1b816a39 100644 (file)
--- a/TODO
+++ b/TODO
@@ -10,8 +10,6 @@ TODO:
        - move channel flags to sql table, include initial state
        - move praise from blootbot.lang to "praise:<something>" in factoids?
        - move lart from blootbot.lang to "lart:<something>" in factoids?
-       - all IsChanConf tests MUST check for >0 as -1 is possible there are a
-         lot of incorrect "if(IsChanConf("foo")) instances now
        - debian BTS frontend "bugs"
        - !country
        - !dinstall
index 01af3048acedbf6c01c4cf3527b08840ae7e0dd3..42a4086fb3bd6b4378a0974df072be7e0430a40c 100644 (file)
@@ -1,6 +1,7 @@
-#v1: blootbot -- blootbot -- written Sun Jan  1 22:59:37 2006
+#v1: blootbot -- InfoBot -- written Fri Jan  6 08:29:25 2006
 
 #botpark
+    -OnJoin
     +RootWarn
     +autojoin
 
index e1cf464a1a68960ac691cf6b98e0002aa5639923..ea94e5b0a566f44a0d2d72b7cc7b26e4f5ad56a4 100644 (file)
@@ -271,10 +271,8 @@ sub readChanFile {
            $chanconf{$chan}{$1} = 1;
 
        } elsif (/^[\s\t]+\-(\S+)$/) {          # bool, false.
-           &DEBUG("deprecated support of negative options.") unless ($cache{negative});
            # although this is supported in run-time configuration.
-           $cache{negative} = 1;
-#          $chanconf{$chan}{$1} = 0;
+           $chanconf{$chan}{$1} = 0;
 
        } elsif (/^[\s\t]+(\S+)[\s\t]+(.*)$/) {# what = val.
            $chanconf{$chan}{$1} = $2;
@@ -297,8 +295,6 @@ sub readChanFile {
        }
     }
 
-    delete $cache{negative};
-
     &status("CHANFILE: Loaded: ".(scalar(keys %chanconf)-1)." chans");
 }
 
index 797e0fbbb05f962d2ec3192c9a5771360a531ae8..e33685c91f712214a267652cb45f453f00a8f1a0 100644 (file)
@@ -241,7 +241,7 @@ sub FactoidStuff {
 
        # lets do it!
 
-       if (&IsParam("factoidDeleteDelay") or &IsChanConf("factoidDeleteDelay")) {
+       if (&IsParam("factoidDeleteDelay") or &IsChanConf("factoidDeleteDelay") > 0) {
            if (!($isop or $isau) and $faqtoid =~ / #DEL#$/) {
                &msg($who, "cannot delete it ($faqtoid).");
                return;
@@ -290,7 +290,7 @@ sub FactoidStuff {
 
        my $i = 0;
        $i++ if (&IsParam("factoidDeleteDelay"));
-       $i++ if (&IsChanConf("factoidDeleteDelay"));
+       $i++ if (&IsChanConf("factoidDeleteDelay") > 0);
        if (!$i) {
            &performReply("safe delete has been disable so what is there to undelete?");
            return;
index 5b2610501fb163664e5cc2caed88b1a0b271bec1..44fd742557934a433aaced5c02ac23cffd985c16 100644 (file)
@@ -33,7 +33,7 @@ sub doQuestion {
 
     if (!$addressed) {
        return '' unless ($finalQMark);
-       return '' unless &IsChanConf("minVolunteerLength");
+       return '' unless &IsChanConf("minVolunteerLength") > 0;
        return '' if (length $query < &::getChanConf('minVolunteerLength'));
     } else {
        ### TODO: this should be caught in Process.pl?
@@ -93,7 +93,7 @@ sub doQuestion {
     $query =~ s/^\s+|\s+$//g; # bleh. hacked.
     push(@query, $query) if ($query ne $x);
 
-    if (&IsChanConf("factoidArguments")) {
+    if (&IsChanConf("factoidArguments") > 0) {
        $result = &factoidArgs($query[0]);
 
        return $result if (defined $result);
@@ -154,7 +154,7 @@ sub doQuestion {
     }
 
     ### TODO: Use &Forker(); move function to Debian.pl
-    if (&IsChanConf('debianForFactoid')) {
+    if (&IsChanConf('debianForFactoid') > 0) {
        &loadMyModule('Debian');
        $result = &Debian::DebianFind($query);  # ???
        ### TODO: debian module should tell, through shm, that it went
index 915eec1b45aefbe6ec8d822fc5bc48a12ce57f50..400012e52387e126765c803dba173bf3966c8f82 100644 (file)
@@ -54,7 +54,7 @@ sub update {
 
     # factoid arguments handler.
     # must start with a non-variable
-    if (&IsChanConf("factoidArguments") and $lhs =~ /^[^\$]+.*\$/) {
+    if (&IsChanConf("factoidArguments") > 0 and $lhs =~ /^[^\$]+.*\$/) {
        &status("Update: Factoid Arguments found.");
        &status("Update: orig lhs => '$lhs'.");
        &status("Update: orig rhs => '$rhs'.");
index 7eecd58ac8f43eeb89b972e60e1c5849bc5fcb70..b121fdf7c5e7e0ca74b9e13868480e488eb3ca05 100644 (file)
@@ -895,7 +895,7 @@ sub closeDCC {
 sub joinfloodCheck {
     my($who,$chan,$userhost) = @_;
 
-    return unless (&IsChanConf("joinfloodCheck"));
+    return unless (&IsChanConf("joinfloodCheck") > 0);
 
     if (exists $netsplit{lc $who}) {   # netsplit join.
        &DEBUG("joinfloodCheck: $who was in netsplit; not checking.");
index 1d1ea4711631e5825a8f84665b381c20e5637d4f..200ddfdcbed83c3756f0db66fefacd1bcf55c665 100644 (file)
@@ -91,7 +91,7 @@ sub hookMsg {
     if ($msgType =~ /private/) {
        # private messages.
        $addressed = 1;
-       if (&IsChanConf('addressCharacter')) {
+       if (&IsChanConf('addressCharacter') > 0) {
            $addressCharacter = getChanConf('addressCharacter');
            if ($message =~ s/^\Q$addressCharacter\E//) {
                &msg($who, "The addressCharacter \"$addressCharacter\" is to get my attention in a normal channel. Please leave it off when messaging me directly.");
@@ -101,7 +101,7 @@ sub hookMsg {
        # public messages.
        # addressing revamped by the xk.
        ### below needs to be fixed...
-       if (&IsChanConf('addressCharacter')) {
+       if (&IsChanConf('addressCharacter') > 0) {
            $addressCharacter = getChanConf('addressCharacter');
            if ($message =~ s/^\Q$addressCharacter\E//) {
                $addrchar  = 1;
@@ -141,7 +141,7 @@ sub hookMsg {
     if ($addressed) {
        my $time = $flood{$floodwho}{$message} || 0;
 
-       if ($msgType eq "public" and (time() - $time < $interval)) {
+       if (!&hasFlag("o") and $msgType eq "public" and (time() - $time < $interval)) {
            ### public != personal who so the below is kind of pointless.
            my @who;
            foreach (keys %flood) {
@@ -183,7 +183,7 @@ sub hookMsg {
        }
 
        $flood{$floodwho}{$message} = time();
-    } elsif ($msgType eq "public" and &IsChanConf("kickOnRepeat")) {
+    } elsif ($msgType eq "public" and &IsChanConf("kickOnRepeat") > 0) {
        # unaddressed, public only.
 
        ### TODO: use a separate "short-time" hash.
@@ -241,7 +241,7 @@ sub hookMsg {
        $seencache{$who}{'msg'}  = $orig{message};
        $seencache{$who}{'msgcount'}++;
     }
-    if (&IsChanConf("minVolunteerLength")) {
+    if (&IsChanConf("minVolunteerLength") > 0) {
        # FIXME hack to treat unaddressed as if using addrchar
        $addrchar = 1;
     }
@@ -294,7 +294,7 @@ sub chanLimitVerify {
     $chan      = $c;
     my $l      = $channels{$chan}{'l'};
 
-    return unless (&IsChanConf("chanlimitcheck"));
+    return unless (&IsChanConf("chanlimitcheck") > 0);
 
     if (scalar keys %netsplit) {
        &WARN("clV: netsplit active (1, chan = $chan); skipping.");
@@ -349,7 +349,7 @@ sub chanServCheck {
        &DEBUG("chanServCheck: lowercased chan ($chan)");
     }
 
-    if (! &IsChanConf("chanServ_ops") ) {
+    if (! &IsChanConf("chanServ_ops") > 0) {
        return 0;
     }
 
index 542ba63643a5b28ade0797f1f1babf113e62c241..d105d8e366b8e981f28c55ce16a3fcb7c9eb49db 100644 (file)
@@ -171,7 +171,7 @@ sub on_endofmotd {
     }
     # end of first time run.
 
-    if (&IsChanConf('Wingate')) {
+    if (&IsChanConf('Wingate') > 0) {
        my $file = "$bot_base_dir/$param{'ircUser'}.wingate";
        open(IN, $file);
        while (<IN>) {
@@ -580,15 +580,15 @@ sub on_join {
 
     ### ROOTWARN:
     &rootWarn($who,$user,$host,$chan) if (
-               &IsChanConf('RootWarn') &&
+               &IsChanConf('RootWarn') > 0 &&
                $user =~ /^~?r(oo|ew|00)t$/i
     );
 
     ### emit a message based on who just joined
-        &onjoin($who,$user,$host,$chan) if (&IsChanConf('OnJoin'));
+        &onjoin($who,$user,$host,$chan) if (&IsChanConf('OnJoin') > 0);
 
     ### NEWS:
-    if (&IsChanConf('News') && &IsChanConf('newsKeepRead')) {
+    if (&IsChanConf('News') > 0 && &IsChanConf('newsKeepRead') > 0) {
        if (!&loadMyModule('News')) {   # just in case.
            &DEBUG('could not load news.');
        } else {
@@ -597,7 +597,7 @@ sub on_join {
     }
 
     ### botmail:
-    if (&IsChanConf('botmail')) {
+    if (&IsChanConf('botmail') > 0) {
        &botmail::check(lc $who);
     }
 
@@ -974,7 +974,7 @@ sub on_quit {
 
        # chanlimit code.
        foreach $chan ( &getNickInChans($nick) ) {
-           next unless ( &IsChanConf("chanlimitcheck") );
+           next unless ( &IsChanConf("chanlimitcheck") > 0);
            next unless ( exists $channels{$_}{'l'} );
 
            &DEBUG("on_quit: netsplit detected on $_; disabling chan limit.");
@@ -1070,7 +1070,7 @@ sub on_topic {
        &status(">>> topic/$b_blue$chan$ob by $b_cyan$nick$ob -> $topic");
     } else {                                           # join.
        my ($nick, $chan, $topic) = $event->args;
-       if (&IsChanConf('Topic')) {
+       if (&IsChanConf('Topic') > 0) {
            $topic{$chan}{'Current'}    = $topic;
            &topicAddHistory($chan,$topic);
        }
index d18a35dfdc1eebe1b3a736e60b63b236e2de09a3..8d8f9e24cc577c2170d38e9b986d6fbcf85edbdb 100644 (file)
@@ -924,12 +924,12 @@ sub kernelLoop {
 }
 
 sub wingateCheck {
-    return unless &IsChanConf('Wingate');
+    return unless &IsChanConf('Wingate') > 0;
 
     ### FILE CACHE OF OFFENDING WINGATES.
     foreach (grep /^$host$/, @wingateBad) {
        &status("Wingate: RUNNING ON $host BY $who");
-       &ban("*!*\@$host", "") if &IsChanConf('wingateBan');
+       &ban("*!*\@$host", "") if &IsChanConf('wingateBan') > 0;
 
        my $reason      = &getChanConf('wingateKick');
 
index fc6f037418788d7cbb34c1388df9e66fd25b78d1..bf95b602216638c250c00dae377f83a13fe2f12d 100644 (file)
@@ -593,7 +593,7 @@ sub hasProfanity {
 sub IsChanConfOrWarn {
     my ($param) = @_;
 
-    if (&IsChanConf($param)) {
+    if (&IsChanConf($param) > 0) {
        return 1;
     } else {
        ### TODO: specific reason why it failed.
index c82b5772730d04daad16574ef74dd6338ac74849..25b049c28d5fb1f4aa4a4a47d0706700a933a4d1 100644 (file)
@@ -119,7 +119,7 @@ sub Parse {
        my $state = ($1) ? 0 : 1;
 
        # TODO: don't notify even if "News" is called.
-       if (!&::IsChanConf("newsNotifyAll")) {
+       if (&::IsChanConf("newsNotifyAll") <= 0) {
            &::DEBUG("news: chan => $chan, ::chan => $::chan.");
            &::notice($who, "not available for this channel or disabled altogether.");
            return;
@@ -371,7 +371,7 @@ sub list {
        return;
     }
 
-    if (&::IsChanConf("newsKeepRead")) {
+    if (&::IsChanConf("newsKeepRead") > 0) {
        my $x = $::newsuser{$chan}{$who};
 
        if (defined $x and ($x == 0 or $x == -1)) {
@@ -751,8 +751,7 @@ sub latest {
     }
 
     $::chan    = $chan;
-    my $x = &::IsChanConf("newsNotifyAll");
-    return if (!$x);
+    return if (&::IsChanConf("newsNotifyAll") <= 0);
 
     # I don't understand this code ;)
     $t = 1 if (!defined $t);
@@ -792,7 +791,7 @@ sub latest {
     # scalar @new, !$flag
     my $unread = scalar @new;
     my $total  = scalar keys %{ $::news{$chan} };
-    if (!$flag && !&::IsChanConf("newsTellUnread")) {
+    if (!$flag && &::IsChanConf("newsTellUnread") <= 0) {
        return;
     }
 
index ccb526b74ddc78089bc7f5121bb5dd3b7ea8242b..ba82171854be7a2c1a1c50939c70384bb3cc1be5 100644 (file)
@@ -197,8 +197,8 @@ sub getChanConfList {
 
     foreach (keys %chanconf) {
        my $chan        = $_;
-#      &DEBUG("chan => $chan");
        my @array       = grep /^$param$/, keys %{ $chanconf{$chan} };
+       #&DEBUG("gCCL param => $param, chan => $chan, keys => " . join(':',keys %{ $chanconf{$chan} }) . " array => " . join(':', @array)) if ($param eq 'whatever');
 
        next unless (scalar @array);
 
@@ -206,7 +206,7 @@ sub getChanConfList {
            &WARN("multiple items found?");
        }
 
-       if ($array[0] eq "0") {
+       if ($chanconf{$chan}{$param} eq "0") {
            $chan{$chan}        = -1;
        } else {
            $chan{$chan}        =  1;
@@ -222,7 +222,9 @@ sub getChanConfList {
 # Return: 1 for enabled, 0 for passive disable, -1 for active disable.
 sub IsChanConf {
     my($param) = shift;
-    my $debug  = 0;    # knocked tons of bugs with this! :)
+
+    # knocked tons of bugs with this! :)
+    my $debug  = 0 # 1 if ($param eq "whatever");
 
     if (!defined $param) {
        &WARN("IsChanConf: param == NULL.");
@@ -236,7 +238,7 @@ sub IsChanConf {
        return 1;
     }
 
-    $chan      ||= "_default";
+    $chan ||= "_default";
 
     my $old = $chan;
     if ($chan =~ tr/A-Z/a-z/) {
@@ -254,9 +256,11 @@ sub IsChanConf {
     }
 
 ### debug purposes only.
-#    &DEBUG("param => $param, msgType => $msgType.");
-#    foreach (keys %chan) {
-#      &DEBUG("   $_ => $chan{$_}");
+#    if ($debug) {
+#      &DEBUG("param => $param, msgType => $msgType.");
+#      foreach (keys %chan) {
+#          &DEBUG("   $_ => $chan{$_}");
+#      }
 #    }
 
     if ($nomatch) {
@@ -267,31 +271,15 @@ sub IsChanConf {
        } else {
            &DEBUG("ICC: other: 0 ($param)") if ($debug);
        }
-
        return $chan{$chan} || $chan{_default} || 0;
-    }
-
-    if ($msgType eq "public") {
+    } elsif ($msgType =~ /^(public|private)$/i) {
        if ($chan{$chan}) {
-           &DEBUG("ICC: public: $chan{$chan} ($chan/$param)") if ($debug);
+           &DEBUG("ICC: $msgType: $chan{$chan} ($chan/$param)") if ($debug);
        } elsif ($chan{_default}) {
-           &DEBUG("ICC: public: $chan{_default} (_default/$param)") if ($debug);
-       } else {
-           &DEBUG("ICC: public: 0 ($param)") if ($debug);
-       }
-
-       return $chan{$chan} || $chan{_default} || 0;
-    }
-
-    if ($msgType eq "private") {
-       if ($chan{_default}) {
-           &DEBUG("ICC: private: $chan{_default} (_default/$param)") if ($debug);
-       } elsif ($chan{$chan}) {
-           &DEBUG("ICC: private: $chan{$chan} ($chan/$param) (hack)") if ($debug);
+           &DEBUG("ICC: $msgType: $chan{_default} (_default/$param)") if ($debug);
        } else {
-           &DEBUG("ICC: private: 0 ($param)") if ($debug);
+           &DEBUG("ICC: $msgType: 0 ($param)") if ($debug);
        }
-
        return $chan{$chan} || $chan{_default} || 0;
     }
 
index 961b90b7a3d8713ab8a6c020c085d8789f8061c2..bcbd3282a50665e8c1cfd1d80a21d5cc93b22557 100644 (file)
@@ -140,7 +140,7 @@ sub loadMyModulesNow {
            next;
        }
 
-       if (!&IsParam($_) and !&IsChanConf($_) and !&getChanConfList($_)) {
+       if (!&IsParam($_) and &IsChanConf($_) <= 0 and !&getChanConfList($_)) {
            &DEBUG("loadMyModuleNow: $_ (2) not loaded.");
            next;
        }