/var/www/www.irssi.org-old/scripts/html/autowhois_simple.pl
1 # Simple and LIGHT version of script /WHOIS'ing all who
2 # send you a private message. Makes /WHOIS once per person,
3 # only when the query window has been created
4 # and therefore works only with irssi with
5 # default query window behaviour.
6 use Irssi;
7 use vars qw($VERSION %IRSSI);
8
9 $VERSION = "0.1";
10 %IRSSI = (
11 authors=> "Janne Mikola",
12 contact=> "janne@mikola.info",
13 name=> "autowhois_simple",
14 description=> "/WHOIS anyone querying you automatically.",
15 license=> "GPL",
16 url=> "http://www.mikola.info",
17 changed=> "14th of July, 2008",
18 changes=> "v0.1: Initial release"
19 );
20
21 # Global
22 $handle_this_query = 0;
23
24 # Checks the birth of a new query window.
25 sub new_query {
26 $handle_this_query = 1;
27 }
28
29 # Does the WHOIS if privmsg is in a new query window.
30 sub make_whois {
31 if($handle_this_query) {
32 my ($server, $msg, $nick, $addr) = @_;
33 $server->command("whois $nick");
34 $handle_this_query = 0;
35 }
36 }
37
38 Irssi::signal_add_first('query created', 'new_query');
39 Irssi::signal_add('message private', 'make_whois');