/usr/share/irssi/scripts/tracknick.pl is in irssi-scripts 20131030.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | # created for irssi 0.7.98, Copyright (c) 2000 Timo Sirainen
# Are you ever tired of those people who keep changing their nicks?
# Or maybe you just don't like someone's nick?
# This script lets you see them with the real nick all the time no matter
# what nick they're currently using.
# Features:
# - when you first join to channel the nick is detected from real name
# - when the nick join to channel, it's detected from host mask
# - keeps track of parts/quits/nick changes
# - /find[realnick] command for seeing the current "fake nick"
# - all public messages coming from the nick are displayed as coming from
# the real nick.
# - all other people's replies to the fake nick are changed to show the
# real nick instead ("fakenick: hello" -> "realnick: hello")
# - if you reply to the real nick, it's automatically changed to the
# fake nick
# TODO:
# - ability to detect always from either address or real name (send whois
# requests after join)
# - don't force the trackchannel
# - nick completion should complete to the real nick too (needs changes
# to irssi code, perl module doesn't recognize "completion word" signal)
# - support for runtime configuration + multiple nicks
# - support for /whois and some other commands? private messages?
use Irssi;
use Irssi::Irc;
use vars qw($VERSION %IRSSI);
$VERSION = "0.01";
%IRSSI = (
authors => "Timo Sirainen",
contact => "tss\@iki.fi",
name => "track nick",
description => "Are you ever tired of those people who keep changing their nicks? Or maybe you just don't like someone's nick? This script lets you see them with the real nick all the time no matter what nick they're currently using.",
license => "Public Domain",
url => "http://irssi.org/",
changed => "2002-03-04T22:47+0100"
);
# change these to the values you want them to be
# change these to the values you want them to be
my $trackchannel = '#channel';
my $realnick = 'nick';
my $address_regexp = 'user@address.fi$';
my $realname_regexp = 'first.*lastname';
my $fakenick = '';
sub event_nick {
my ($newnick, $server, $nick, $address) = @_;
$newnick = substr($newnick, 1) if ($newnick =~ /^:/);
$fakenick = $newnick if ($nick eq $fakenick)
}
sub event_join {
my ($data, $server, $nick, $address) = @_;
if (!$fakenick && $data eq $trackchannel &&
$address =~ /$address_regexp/) {
$fakenick = $nick;
}
}
sub event_part {
my ($data, $server, $nick, $address) = @_;
my ($channel, $reason) = $data =~ /^(\S*)\s:(.*)/;
$fakenick = '' if ($fakenick eq $nick && $channel eq $trackchannel);
}
sub event_quit {
my ($data, $server, $nick, $address) = @_;
$fakenick = '' if ($fakenick eq $nick);
}
sub event_wholist {
my ($channel) = @_;
find_realnick($channel) if ($channel->{name} eq $trackchannel);
}
sub find_realnick {
my ($channel) = @_;
my @nicks = $channel->nicks();
$fakenick = '';
foreach $nick (@nicks) {
my $realname = $nick->{realname};
if ($realname =~ /$realname_regexp/i) {
$fakenick = $nick->{nick};
break;
}
}
}
sub sig_public {
my ($server, $msg, $nick, $address, $target) = @_;
return if ($target ne $trackchannel || !$fakenick ||
$fakenick eq $realnick);
if ($nick eq $fakenick) {
# text sent by fake nick - change it to real nick
send_real_public($server, $msg, $nick, $address, $target);
return;
}
if ($msg =~ /^$fakenick([:',].*)/) {
# someone's message starts with the fake nick,
# automatically change it to real nick
$msg = $realnick.$1;
Irssi::signal_emit("message public", $server, $msg,
$nick, $address, $target);
Irssi::signal_stop();
}
}
sub send_real_public
{
my ($server, $msg, $nick, $address, $target) = @_;
my $channel = $server->channel_find($target);
return if (!$channel);
my $nickrec = $channel->nick_find($nick);
return if (!$nickrec);
# create temporarily the nick to the nick list so that
# nick mode can be displayed correctly
my $newnick = $channel->nick_insert($realnick,
$nickrec->{op},
$nickrec->{voice}, 0);
Irssi::signal_emit("message public", $server, $msg,
$realnick, $address, $target);
$channel->nick_remove($newnick);
Irssi::signal_stop();
}
sub sig_send_text {
my ($data, $server, $item) = @_;
return if (!$fakenick || !$item ||
$item->{name} ne $trackchannel);
if ($fakenick ne $realnick && $data =~ /^$realnick([:',].*)/) {
# sending message to realnick, change it to fakenick
$data = $fakenick.$1;
Irssi::signal_emit("send text", $data, $server, $item);
Irssi::signal_stop();
}
}
sub cmd_realnick {
if ($fakenick) {
Irssi::print("$realnick is currently with nick: $fakenick");
} else {
Irssi::print("I can't find $realnick currently.");
}
}
my $channel = Irssi::channel_find($trackchannel);
find_realnick($channel) if ($channel);
Irssi::signal_add('event nick', 'event_nick');
Irssi::signal_add('event join', 'event_join');
Irssi::signal_add('event part', 'event_part');
Irssi::signal_add('event quit', 'event_quit');
Irssi::signal_add('message public', 'sig_public');
Irssi::signal_add('send text', 'sig_send_text');
Irssi::signal_add('channel wholist', 'event_wholist');
Irssi::command_bind("find$realnick", 'cmd_realnick');
|