]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHelpers.pl
standard TODO: and FIXME:
[infobot.git] / src / IRC / IrcHelpers.pl
index 2ce1acb91259eefee97eb714fd6b1511ee6b5ae9..aa69201cc4573a615a0061a2560bc5d9e8887df2 100644 (file)
@@ -6,8 +6,6 @@
 #        NOTE: Based on code by Kevin Lenzo & Patrick Cole  (c) 1997
 #
 
-if (&IsParam("useStrict")) { use strict; }
-
 #######################################################################
 ####### IRC HOOK HELPERS   IRC HOOK HELPERS   IRC HOOK HELPERS ########
 #######################################################################
@@ -117,12 +115,15 @@ sub hookMsg {
 
     # Determine floodwho.
     my $c      = "_default";
-    if ($msgType =~ /public/i) {               # public.
+    if ($msgType =~ /public/i) {
+       # public.
        $floodwho = $c = lc $chan;
-    } elsif ($msgType =~ /private/i) { # private.
+    } elsif ($msgType =~ /private/i) {
+       # private.
        $floodwho = lc $who;
-    } else {                           # dcc?
-       &DEBUG("FIXME: floodwho = ???");
+    } else {
+       # dcc?
+       &FIXME("floodwho = ???");
     }
 
     my $val = &getChanConfDefault("floodRepeat", "2:5", $c);
@@ -144,12 +145,10 @@ sub hookMsg {
 
            return if ($lobotomized);
 
-           if (scalar @who) {
-               &msg($who, "you already said what ".
-                               join(' ', @who)." have said.");
-           } else {
-               &msg($who,"Someone already said that ". (time - $time) ." seconds ago" );
+           if (!scalar @who) {
+               push(@who,"Someone");
            }
+           &msg($who,join(' ', @who)." already said that ". (time - $time) ." seconds ago" );
 
            ### TODO: delete old floodwarn{} keys.
            my $floodwarn = 0;
@@ -196,10 +195,12 @@ sub hookMsg {
 
        my $i = scalar keys %{ $flood{$floodwho} };
        if ($i > $count) {
-           &msg($who,"overflow of messages ($i > $count)");
+           my $expire = $param{'ignoreAutoExpire'} || 5;
+
+#          &msg($who,"overflow of messages ($i > $count)");
+           &msg($who,"Too many queries from you, ignoring for $expire minutes.");
            &status("FLOOD overflow detected from $floodwho; ignoring");
 
-           my $expire = $param{'ignoreAutoExpire'} || 5;
            &ignoreAdd("*!$uh", $chan, $expire, "flood overflow auto-detected.");
            return;
        }
@@ -221,8 +222,8 @@ sub hookMsg {
     }
     push(@ignore, keys %{ $ignore{"*"} }) if (exists $ignore{"*"});
 
-    if ((!$skipmessage or &IsChanConf("seenStoreAll")) and
-       &IsChanConf("seen") and
+    if ((!$skipmessage or &IsChanConf("seenStoreAll") > 0) and
+       &IsChanConf("seen") > 0 and
        $msgType =~ /public/
     ) {
        $seencache{$who}{'time'} = time();
@@ -244,7 +245,7 @@ sub hookMsg {
        # better to ignore an extra message than to allow one to get
        # through, although it would be better to go through ignore
        # checking again.
-       if (time() - $cache{ignoreCheckTime} > 60) {
+       if (time() - ($cache{ignoreCheckTime} || 0) > 60) {
            &ignoreCheck();
        }
 
@@ -266,6 +267,13 @@ sub hookMsg {
 #      &DEBUG("IrcHooks: process returned '$_'.");
     }
 
+    # hack to remove +o from ppl with +O flag.
+    if (exists $users{$userHandle} && exists $users{$userHandle}{FLAGS} &&
+       $users{$userHandle}{FLAGS} =~ /O/
+    ) {
+       $users{$userHandle}{FLAGS} =~ s/o//g;
+    }
+
     return;
 }
 
@@ -283,7 +291,7 @@ sub chanLimitVerify {
     }
 
     if (!defined $l) {
-       &DEBUG("running chanlimitCheck from chanLimitVerify; FIXME! (chan = $chan)");
+       &DEBUG("$chan: running chanlimitCheck from chanLimitVerify.");
        &chanlimitCheck();
        return;
     }
@@ -308,13 +316,13 @@ sub chanLimitVerify {
 
     &chanServCheck($chan);
 
-    ### todo: unify code with chanlimitcheck()
+    ### TODO: unify code with chanlimitcheck()
     return if ($delta > 5);
 
     &status("clc: big change in limit for $chan ($delta);".
                "going for it. (was: $l; now: ".($count+$plus).")");
 
-    &rawout("MODE $chan +l ".($count+$plus) );
+    $conn->mode($chan, "+l", $count+$plus);
     $cache{chanlimitChange}{$chan} = time();
 }
 
@@ -337,12 +345,12 @@ sub chanServCheck {
     &VERB("chanServCheck($chan) called.",2);
 
     if ( &IsParam("nickServ_pass") and !$nickserv) {
-       &DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)");
-       &rawout("WHO NickServ");
+       $conn->who("NickServ");
        return 0;
     }
+
     # check for first hash then for next hash.
-    # todo: a function for &ischanop()? &isvoice()?
+    # TODO: a function for &ischanop()? &isvoice()?
     if (exists $channels{$chan} and exists $channels{$chan}{'o'}{$ident}) {
        return 0;
     }