Added SILC Thread Queue API
[crypto.git] / apps / irssi / scripts / examples / redirect.pl
1 # Example how to do redirections, we'll grab the output of /WHOIS:
2
3 # /RN - display real name of nick
4
5 use Irssi;
6 use Irssi::Irc;
7 use strict;
8 use vars qw($VERSION %IRSSI);
9
10 $VERSION = "1.00";
11 %IRSSI = (
12     authors     => 'Timo Sirainen',
13     name        => 'redirect',
14     description => 'Redirection example',
15     license     => 'Public Domain'
16 );
17
18 sub cmd_realname {
19         my ($data, $server, $channel) = @_;
20
21         # ignore all whois replies except "No such nick" or the 
22         # first line of the WHOIS reply
23         $server->redirect_event('whois', 1, $data, -1, '', {
24                           'event 402' => 'event 402',
25                           'event 401' => 'event 401',
26                           'event 311' => 'redir whois',
27                           '' => 'event empty' });
28
29         $server->send_raw("WHOIS :$data");
30 }
31
32 sub event_rn_whois {
33         my ($num, $nick, $user, $host, $empty, $realname) = split(/ +/, $_[1], 6);
34         $realname =~ s/^://;
35
36         Irssi::print("%_$nick%_ is $realname");
37 }
38
39 Irssi::command_bind('rn', 'cmd_realname');
40 Irssi::signal_add('redir whois', 'event_rn_whois');