diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/nickignore.pl | |
parent | Initial commit. (diff) | |
download | irssi-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 'scripts/nickignore.pl')
-rw-r--r-- | scripts/nickignore.pl | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/scripts/nickignore.pl b/scripts/nickignore.pl new file mode 100644 index 0000000..bff2d50 --- /dev/null +++ b/scripts/nickignore.pl @@ -0,0 +1,49 @@ +# +# nickignore.pl +# +# ignore minimal changes in nicks (case, special characters) +# +# can also ignore more complex/drastic changes via variable +# 'nickignore_pattern' (use like '/set nickignore_pattern (away|afk)') + +use Irssi; +use Irssi::Irc; +use vars qw($VERSION %IRSSI); +use strict; + + +$VERSION = "0.03"; +%IRSSI = ( + authors => "Kalle 'rpr' Marjola", + contact => "marjola\@iki.fi", + name => "ignore (minimal) nick changes", + description => "Ignores any nick changes when only the case or special characters are modified, like 'rpr -> Rpr' or 'rpr_ -> rpr', with optional pattern for more complicated ignores", + license => "Public Domain", + url => "http://iki.fi/rpr/irssi/nickignore.pl", + changed => "26.8.2003" +); + +sub event_nick { + my ($server, $newnick, $nick, $address) = @_; + + # (debug) Irssi::print("new: $newnick old: $nick"); + $newnick = substr($newnick, 1) if ($newnick =~ /^:/); + + # remove any special characters from nicks + $newnick =~ s/[^a-zA-Z]//g; + $nick =~ s/[^a-zA-Z]//g; + + # if the user has specific other patterns to be used, use it + my $extra_pattern = Irssi::settings_get_str('nickignore_pattern'); + if ($extra_pattern) { + $newnick =~ s/$extra_pattern//g; + $nick =~ s/$extra_pattern//g; + } + + # compare if they are identical (excluding case) + Irssi::signal_stop() if ($newnick =~ m/^$nick$/i); +} + +Irssi::signal_add('event nick', 'event_nick'); + +Irssi::settings_add_str ('misc', 'nickignore_pattern', ''); |