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" }
17 hook_server '352', sub {
18 return EAT_NONE unless 0 <= rindex $_[0][8], '*';
20 my $serv = get_info 'server';
22 return EAT_NONE if $opers{$serv}{$nick};
23 $opers{$serv}{$nick} = 1;
25 my $host = $_[0][4] . '@' . $_[0][5];
27 push @{$chans{$_->{type}}}, $_ for grep $_->{server} eq $serv,
30 my $oldctxt = get_context;
34 set_context $_->{context} or next;
35 user_info $nick or next;
36 print_op $nick, $host;
41 @opchans = @{$chans{1}} unless $onachan;
42 push @opchans, grep !nickcmp($_->{channel}, $nick), @{$chans{3}};
44 set_context $_->{context} or next;
45 print_op $nick, $host;
53 hook_print 'Disconnected', sub {
54 my %servers = map { $_->{server} => 1 }
55 grep { $_->{flags} & 9 and not($_->{flags} & 2) }
58 delete @opers{grep !$servers{$_}, keys %opers};
63 hook_server 'QUIT', sub {
64 my ($nick) = $_[0][0] =~ /^:([^!]+)!/;
66 my $serv = get_info 'server';
67 delete $opers{$serv}{$nick};
73 my ($old, $new) = @{$_[0]};
75 my $ops = $opers{get_info 'server'};
76 if ($ops and $ops->{$old}) {
84 hook_print $_, \&nick_cb for 'Change Nick', 'Your Nick Changing';
86 hook_command 'OPSCAN', sub {
87 my $serv = get_info 'server';
89 print $ph "No information for this network yet\n";
93 my $chan = get_info 'channel';
95 for (get_list 'channels') {
96 if ($_->{type} == 1 and $_->{channel} eq $chan) {
105 @ops = keys %{$opers{$serv}};
108 @ops = map $_->{nick},
109 grep $opers{$serv}{$_->{nick}},
114 print $ph "IRC operators on this $name : \002@ops\n";
116 print $ph "No IRC operators on this $name\n";
121 help_text => 'OPSCAN, scan for IRC operators in the current channel'
124 $ph = Xchat::XPI->new(
127 desc => 'IRC operators scanner',
128 author => 'Vincent Pit (VPIT)',
129 email => 'perl@profvince.com',
130 url => 'http://www.profvince.com',
131 unload => sub { undef %opers },