summaryrefslogtreecommitdiffstats
path: root/scripts/nickignore.pl
blob: bff2d507dd49b9f188c7b6a497b6357775826942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
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', '');