summaryrefslogtreecommitdiffstats
path: root/scripts/mass_hilight_blocker.pl
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 20:19:02 +0000
commit03929dac2a29664878d2c971648a4fe1fb698462 (patch)
tree02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/mass_hilight_blocker.pl
parentInitial commit. (diff)
downloadirssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.tar.xz
irssi-scripts-03929dac2a29664878d2c971648a4fe1fb698462.zip
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--scripts/mass_hilight_blocker.pl62
1 files changed, 62 insertions, 0 deletions
diff --git a/scripts/mass_hilight_blocker.pl b/scripts/mass_hilight_blocker.pl
new file mode 100644
index 0000000..559d02d
--- /dev/null
+++ b/scripts/mass_hilight_blocker.pl
@@ -0,0 +1,62 @@
+# disable hilighting of mass-hilights
+# (messages which contain a lot of nicknames)
+#
+# DESCRIPTION
+# sometimes a jester annoys a channel with a message
+# containing a lot of nicks that are in that channel.
+# this script prevents hilighting of a window in this
+# case. number of nicks in the message is user
+# configurable in the variable mass_highlight_threshold.
+#
+# CHANGELOG
+# * 01.05.2004
+# fixed problems with nicks containing brackets
+# added comments, description and this changelog :)
+# * 30.05.2004
+# first version of the script
+
+use strict;
+use Irssi;
+use vars qw($VERSION %IRSSI);
+$VERSION = "0.4";
+%IRSSI = (
+ authors => "Uli Baumann",
+ contact => "f-zappa\@irc-muenster.de",
+ name => "mass_hilight_blocker",
+ description => "Disables hilighting for messages containing a lot of nicknames",
+ license => "GPL",
+ changed => "Sun Nov 11 15:30:00 CET 2018",
+);
+
+
+sub sig_printtext {
+ my ($dest, $text, $stripped) = @_; # our parameters
+ my $window = $dest->{window}; # where irssi wants to output
+ my $num_nicks=-1; # don't count target's nick
+ my $max_num_nicks=Irssi::settings_get_int('mass_hilight_threshold');
+
+ if ($dest->{level} & MSGLEVEL_HILIGHT)# we solely look at hilighted messages
+ {
+ my $server = $dest->{server}; # get server and channel for target
+ my $channel = $server->channel_find($dest->{target});
+
+ foreach my $nick ($channel->nicks()) # walk through nicks
+ {
+ $nick = $nick->{nick};
+ if ($text =~ /\Q$nick/) # does line contain this nick?
+ {$num_nicks++;} # then increase counter
+ }
+
+ if ($num_nicks>=($max_num_nicks)) # all criteria match?
+ {
+ $dest->{level} = MSGLEVEL_CLIENTCRAP;
+ Irssi::signal_continue($dest, $text, $stripped); # continue with changed level
+ $window->print('mass-hilighting in above message ('.$num_nicks.' nicks)',MSGLEVEL_CLIENTCRAP);
+ }
+ }
+}
+
+# tell irssi to use this and initialize variable if necessary
+
+Irssi::signal_add_first('print text', 'sig_printtext');
+Irssi::settings_add_int('misc','mass_hilight_threshold',3);