]> git.donarmstrong.com Git - infobot.git/blobdiff - src/IRC/IrcHelpers.pl
allow per-channel addressCharacter
[infobot.git] / src / IRC / IrcHelpers.pl
index 18ff34a8b31a32d7fc469a9067db73cbe8a41e78..13f44695b800463a2ff98383c909f2b59055f6d4 100644 (file)
@@ -6,8 +6,6 @@
 #        NOTE: Based on code by Kevin Lenzo & Patrick Cole  (c) 1997
 #
 
-# use strict;  # TODO
-
 #######################################################################
 ####### IRC HOOK HELPERS   IRC HOOK HELPERS   IRC HOOK HELPERS ########
 #######################################################################
@@ -85,6 +83,7 @@ sub hookMsg {
     $message   =~ s/[\cA-\c_]//ig;     # strip control characters
     $message   =~ s/^\s+//;            # initial whitespaces.
     $who       =~ tr/A-Z/a-z/;         # lowercase.
+    my $mynick = $conn->nick();
 
     &showProc();
 
@@ -92,12 +91,19 @@ sub hookMsg {
     if ($msgType =~ /private/) {
        # private messages.
        $addressed = 1;
+       if (&IsChanConf('addressCharacter')) {
+           $addressCharacter = getChanConf('addressCharacter');
+           if ($message =~ s/^\Q$addressCharacter\E//) {
+               &msg($who, "please don't use the the addressCharacter when private messaging");
+           }
+       }
     } else {
        # public messages.
        # addressing revamped by the xk.
        ### below needs to be fixed...
-       if (&IsParam("addressCharacter")) {
-           if ($message =~ s/^\Q$param{'addressCharacter'}\E//) {
+       if (&IsChanConf('addressCharacter')) {
+           $addressCharacter = getChanConf('addressCharacter');
+           if ($message =~ s/^\Q$addressCharacter\E//) {
                $addrchar  = 1;
                $addressed = 1;
            }
@@ -105,7 +111,7 @@ sub hookMsg {
 
        if ($message =~ /^($mask{nick})([\;\:\>\, ]+) */) {
            my $newmessage = $';
-           if ($1 =~ /^\Q$ident\E$/i) {
+           if ($1 =~ /^\Q$mynick\E$/i) {
                $message   = $newmessage;
                $addressed = 1;
            } else {
@@ -117,12 +123,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 +153,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;
@@ -168,11 +175,11 @@ sub hookMsg {
        }
 
        if ($addrchar) {
-           &status("$b_cyan$who$ob is short-addressing me");
+           &status("$b_cyan$who$ob is short-addressing $mynick");
        } elsif ($msgType eq "private") {       # private.
-           &status("$b_cyan$who$ob is /msg'ing me");
+           &status("$b_cyan$who$ob is /msg'ing $mynick");
        } else {                                # public?
-           &status("$b_cyan$who$ob is addressing me");
+           &status("$b_cyan$who$ob is addressing $mynick");
        }
 
        $flood{$floodwho}{$message} = time();
@@ -223,8 +230,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();
@@ -234,9 +241,12 @@ sub hookMsg {
        $seencache{$who}{'msg'}  = $orig{message};
        $seencache{$who}{'msgcount'}++;
     }
-
+    if (&IsChanConf("minVolunteerLength")) {
+       # FIXME hack to treat unaddressed as if using addrchar
+       $addrchar = 1;
+    }
     return if ($skipmessage);
-    return unless (&IsParam("minVolunteerLength") or $addressed);
+    return unless ($addrchar or $addressed);
 
     foreach (@ignore) {
        s/\*/\\S*/g;
@@ -292,7 +302,7 @@ sub chanLimitVerify {
     }
 
     if (!defined $l) {
-       &DEBUG("running chanlimitCheck from chanLimitVerify; FIXME! (chan = $chan)");
+       &DEBUG("$chan: running chanlimitCheck from chanLimitVerify.");
        &chanlimitCheck();
        return;
     }
@@ -317,7 +327,7 @@ 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);".
@@ -346,12 +356,12 @@ sub chanServCheck {
     &VERB("chanServCheck($chan) called.",2);
 
     if ( &IsParam("nickServ_pass") and !$nickserv) {
-       &DEBUG("chanServ_ops($chan): nickserv enabled but not alive? (ircCheck)");
        $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;
     }