]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
bansearch: more improvements
authorDoug Freed <redacted>
Mon, 24 Aug 2020 19:15:24 +0000 (19:15 +0000)
committerDoug Freed <redacted>
Mon, 24 Aug 2020 19:15:24 +0000 (19:15 +0000)
* Simpler set-by-server regex
* Shift mode redirect to block where mode request is sent
* Add debug output and setting to control it

scripts/bansearch.pl

index 49fd606a27196cb44a4214d84bb72726401f7ee9..cc961ad97c6736b934715f9b334d169f4bbb63d2 100644 (file)
@@ -14,7 +14,7 @@ $VERSION = "1.3";
     license     => 'GPLv3+',
 );
 
-my($channel,$person,$nick,$user,$host,$real,$account,$string,$issues,$running,@jchannels,@jchannelstocheck);
+my($channel,$person,$nick,$user,$host,$real,$account,$string,$issues,$running,@jchannels,@jchannelstocheck,$debug);
 
 $running=0;
 
@@ -31,6 +31,7 @@ sub bansearch {
 
         #Clear variables and register redirects
         &reset();
+        $debug = Irssi::settings_get_bool('bansearch_debug');
 
         #Split command arguments into a nick and a channel separated by a space
        ($person,$channel)=split(/ /, $data, 2);
@@ -106,7 +107,7 @@ sub RPL_BANLIST {
     $maskreg=~s/\*/\.\*\?/g;
 
     #We only want to display who set the ban/quiet if it is listed as a person
-    if($setby=~m/^[^!.]+\.[^!]+$/i) {
+    if($setby!~m/!/) {
        $setby='';
     }
     else {
@@ -121,7 +122,7 @@ sub RPL_BANLIST {
                $issues++;
            }
            else {
-#              Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match $account" . $setby);
+               Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match $account" . $setby) if $debug;
            }
        }
        # cannot join other channel
@@ -140,22 +141,22 @@ sub RPL_BANLIST {
        if($maskreg=~m/^\$a$/i) {
            if($account!~m/^0$/) {
                Irssi::active_win()->print(
-                   "$type against \x02$mask\x02 in $banchannel matches identified user." . $setby);
+                   "$type against \x02$mask\x02 in $banchannel matches identified user" . $setby);
                $issues++;
            }
            else {
-#              Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match $account" . $setby);
+               Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match unidentified user" . $setby) if $debug;
            }
        }
        # any unidentified user
        if($maskreg=~m/^\$\~a$/i) {
            if($account=~m/^0$/) {
                Irssi::active_win()->print(
-                   "$type against \x02$mask\x02 in $banchannel matches unidentified user." . $setby);
+                   "$type against \x02$mask\x02 in $banchannel matches unidentified user" . $setby);
                $issues++;
            }
            else {
-#              Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match $account" . $setby);
+               Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match identified user" . $setby) if $debug;
            }
        }
        # ircname
@@ -166,7 +167,7 @@ sub RPL_BANLIST {
                $issues++;
            }
            else {
-#              Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match real name of $real" . $setby);
+               Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match real name of $real" . $setby) if $debug;
            }
        }
        # full match
@@ -178,7 +179,7 @@ sub RPL_BANLIST {
                $issues++;
            }
            else {
-#              Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match $full" . $setby);
+               Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match $full" . $setby) if $debug;
            }
        }
     }
@@ -188,7 +189,7 @@ sub RPL_BANLIST {
            $issues++;
        }
        else {
-#          Irssi::active_win()->print("$type against \x02$mask\x02 does NOT match $string" . $setby);
+           Irssi::active_win()->print("$type against \x02$mask\x02 in $banchannel does NOT match $string" . $setby) if $debug;
        }
     }
 }
@@ -210,12 +211,6 @@ sub RPL_ENDOFBANLIST {
                $server->send_raw("MODE $channel q");
        }
        elsif($data=~m/^Quiet/) {
-               $server->redirect_event('mode channel',1, $channel, 0, undef,
-               {
-                 'event 324' => 'redir rpl_channelmodeis',
-                 '' => 'event empty',
-               }
-               );
                if (@jchannelstocheck) {
                        my $nextchannel = pop(@jchannelstocheck);
                        $server->redirect_event('mode b',1, $nextchannel, 0, undef, 
@@ -228,6 +223,12 @@ sub RPL_ENDOFBANLIST {
                        );
                        $server->send_raw("MODE $nextchannel b");
                } else {
+                       $server->redirect_event('mode channel',1, $channel, 0, undef,
+                       {
+                         'event 324' => 'redir rpl_channelmodeis',
+                         '' => 'event empty',
+                       }
+                       );
                        $server->send_raw("MODE $channel");
                }
        }
@@ -415,5 +416,6 @@ sub register_redirects {
 }
 
 Irssi::command_bind('bansearch', 'bansearch');
+Irssi::settings_add_bool('bansearch', 'bansearch_debug', 0);
 
 # vim:set ts=8 sw=4:
git clone https://git.99rst.org/PROJECT