1# disable hilighting of mass-hilights 2# (messages which contain a lot of nicknames) 3# 4# DESCRIPTION 5# sometimes a jester annoys a channel with a message 6# containing a lot of nicks that are in that channel. 7# this script prevents hilighting of a window in this 8# case. number of nicks in the message is user 9# configurable in the variable mass_highlight_threshold. 10# 11# CHANGELOG 12# * 01.05.2004 13# fixed problems with nicks containing brackets 14# added comments, description and this changelog :) 15# * 30.05.2004 16# first version of the script 17 18use strict; 19use Irssi; 20use vars qw($VERSION %IRSSI); 21$VERSION = "0.4"; 22%IRSSI = ( 23 authors => "Uli Baumann", 24 contact => "f-zappa\@irc-muenster.de", 25 name => "mass_hilight_blocker", 26 description => "Disables hilighting for messages containing a lot of nicknames", 27 license => "GPL", 28 changed => "Sun Nov 11 15:30:00 CET 2018", 29); 30 31 32sub sig_printtext { 33 my ($dest, $text, $stripped) = @_; # our parameters 34 my $window = $dest->{window}; # where irssi wants to output 35 my $num_nicks=-1; # don't count target's nick 36 my $max_num_nicks=Irssi::settings_get_int('mass_hilight_threshold'); 37 38 if ($dest->{level} & MSGLEVEL_HILIGHT)# we solely look at hilighted messages 39 { 40 my $server = $dest->{server}; # get server and channel for target 41 my $channel = $server->channel_find($dest->{target}); 42 43 foreach my $nick ($channel->nicks()) # walk through nicks 44 { 45 $nick = $nick->{nick}; 46 if ($text =~ /\Q$nick/) # does line contain this nick? 47 {$num_nicks++;} # then increase counter 48 } 49 50 if ($num_nicks>=($max_num_nicks)) # all criteria match? 51 { 52 $dest->{level} = MSGLEVEL_CLIENTCRAP; 53 Irssi::signal_continue($dest, $text, $stripped); # continue with changed level 54 $window->print('mass-hilighting in above message ('.$num_nicks.' nicks)',MSGLEVEL_CLIENTCRAP); 55 } 56 } 57} 58 59# tell irssi to use this and initialize variable if necessary 60 61Irssi::signal_add_first('print text', 'sig_printtext'); 62Irssi::settings_add_int('misc','mass_hilight_threshold',3); 63