1 package Xchat::VPIT::Opers;
8 use lib get_info 'xchatdir';
11 our $VERSION = '0.03';
15 sub print_op { print $ph "\002$_[0]\002 ($_[1]) \002is an IRC operator\n"; 1 }
17 hook_server '352', sub {
18 return EAT_NONE unless 0 <= rindex $_[0][8], '*';
19 my $serv = get_info 'server';
21 if (!$opers{$serv}{$nick}) {
22 $opers{$serv}{$nick} = 1;
23 my $host = $_[0][4].'@'.$_[0][5];
25 push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv,
27 my $oldctxt = get_context;
28 my $onachan = grep $_, map {
29 set_context $_->{context}
31 and print_op $nick, $host
34 set_context $_->{context}
35 and print_op $nick, $host
36 } for ($onachan ? () : @{$chans{1}}),
37 grep !nickcmp($_->{channel}, $nick), @{$chans{3}};
43 hook_print 'Disconnected', sub {
44 my %servers = map { $_->{server} => 1 }
45 grep { $_->{flags} & 9 && not $_->{flags} & 2 }
47 delete $opers{$_} for grep { !$servers{$_} } keys %opers;
51 hook_server 'QUIT', sub {
52 my ($nick) = $_[0][0] =~ /^:([^!]+)!/;
53 my $serv = get_info 'server';
54 delete $opers{$serv}{$nick};
59 my ($old, $new) = @{$_[0]};
60 my $ops = $opers{get_info 'server'};
61 if ($ops && $ops->{$old}) {
68 hook_print $_, \&nick_cb for ('Change Nick', 'Your Nick Changing');
70 hook_command 'OPSCAN', sub {
71 my $serv = get_info 'server';
73 print $ph "No information for this network yet\n";
76 my ($chan, $isnet) = (get_info('channel'), 0);
77 for (get_list 'channels') {
78 if ($_->{type} eq 1 && $_->{channel} eq $chan) {
83 my ($name, @ops) = ($isnet) ? ('network', keys %{$opers{$serv}})
84 : ('channel', map $_->{nick},
85 grep $opers{$serv}{$_->{nick}},
88 print $ph 'IRC operators on this '.$name." : \002@ops\n";
90 print $ph 'No IRC operators on this '.$name."\n";
94 help_text => 'OPSCAN, scan for IRC operators in the current channel'
97 $ph = new Xchat::XPI name => 'Operators',
99 desc => 'IRC operators scanner',
100 author => 'Vincent Pit (VPIT)',
101 email => 'perl@profvince.com',
102 url => 'http://www.profvince.com',
103 unload => sub { undef %opers; };