]> git.99rst.org Git - irssi-scripts.irssi.org.git/commitdiff
(quakequit) New functions for interacting with quitlist.
authorphyber <redacted>
Fri, 9 Jan 2015 15:50:38 +0000 (15:50 +0000)
committerbw1 <redacted>
Sun, 14 Jan 2018 21:00:15 +0000 (22:00 +0100)
scripts/quakequit.pl

index 2efae544370a6a67730d58b4a3af619a8c2120c2..2f485159bfaeae1e7ae1ac11c7ac35a3c059d7bf 100644 (file)
@@ -41,9 +41,6 @@ $VERSION = "1.0";
 # any errors that might happen.
 my $debug = 0;
 
-# Hash to store our temporary ignores in.
-my %quits;
-
 # Debug line output.
 sub dprint {
        my ($msg) = @_;
@@ -52,6 +49,27 @@ sub dprint {
        }
 }
 
+# Hash to store our temporary ignores in.
+my %quits;
+
+sub in_quitlist {
+       my ($tag, $nick) = @_;
+       return $quits{$tag . ':' . $nick};
+}
+
+sub quitlist_add {
+       my ($tag, $nick) = @_;
+       $quits{$tag . ':' . $nick} = 1;
+}
+
+# Remove entries from the quits hash.
+sub purge_nick {
+       my ($nick) = @_;
+       dprint("Purging $nick from the quits list");
+       delete $quits{$nick};
+       return 0;
+}
+
 # Return 1 if we should process the tag, otherwise 0.
 sub process_tag {
        my ($tag) = @_;
@@ -64,14 +82,6 @@ sub process_tag {
        return 0;
 }
 
-# Remove entries from the quits hash.
-sub purge_nick {
-       my ($nick) = @_;
-       dprint("Purging $nick from the quits list");
-       delete $quits{$nick};
-       return 0;
-}
-
 # Process the 'message join' signal. (/JOIN)
 sub message_join {
        my ($server_rec, $channel, $nick, $addr) = @_;
@@ -91,11 +101,14 @@ sub message_join {
 
        dprint("Processing JOIN $tag: $nick $addr");
 
-       # If the joining nick is in our quit hash, don't show the join.
-       if ($quits{$tag.':'.$nick}) {
-               Irssi::signal_stop();
+       # Return if they're not in the quitlist.
+       if (!in_quitlist($tag, $nick)) {
                return 0;
        }
+
+       # Finally, stop the signal. They are in the quitlist.
+       Irssi::signal_stop();
+       return 0;
 }
 
 # Process the 'message quit' signal. (/QUIT)
@@ -116,7 +129,7 @@ sub message_quit {
 
        # If the quit message is registered, add the person to our quit hash
        # and abort the signal.
-       $quits{$tag.':'.$nick} = 1;
+       quitlist_add($tag, $nick);
        Irssi::timeout_add_once(1000, 'purge_nick', $tag.':'.$nick);
        Irssi::signal_stop();
        return 0;
@@ -157,11 +170,14 @@ sub message_irc_mode {
        foreach my $target (@targets) {
                dprint("Processing $target");
 
-               if ($quits{$tag.':'.$target}) {
-                       dprint("Found $target in target list, stopping signal");
-                       Irssi::signal_stop();
-                       return 0;
+               # Proceed to next if target isn't in the quitlist.
+               if (!in_quitlist($tag, $target)) {
+                       next;
                }
+
+               dprint("Found $target in target list, stopping signal");
+               Irssi::signal_stop();
+               return 0;
        }
 }
 
git clone https://git.99rst.org/PROJECT