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 (rindex $_[0][8], '*') >= 0;
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}) && user_info($nick) && print_op($nick, $host)
32 set_context($_->{context}) && print_op($nick, $host)
33 } for ($onachan ? () : @{$chans{1}}),
34 grep { !nickcmp($_->{channel}, $nick) } @{$chans{3}};
40 hook_print 'Disconnected', sub {
41 my %servers = map { $_->{server} => 1 }
42 grep { $_->{flags} & 9 && not $_->{flags} & 2 }
44 delete $opers{$_} for grep { !$servers{$_} } keys %opers;
48 hook_server 'QUIT', sub {
49 my ($nick) = ($_[0][0] =~ /^:([^!]+)!/);
50 my $serv = get_info 'server';
51 delete $opers{$serv}{$nick};
56 my ($old, $new) = @{$_[0]};
57 my $ops = $opers{get_info 'server'};
58 if ($ops && $ops->{$old}) {
65 hook_print $_, \&nick_cb for ('Change Nick', 'Your Nick Changing');
67 hook_command 'OPSCAN', sub {
68 my $serv = get_info 'server';
70 print $ph "No information for this network yet\n";
73 my ($chan, $isnet) = (get_info('channel'), 0);
74 for (get_list 'channels') {
75 if ($_->{type} eq 1 && $_->{channel} eq $chan) { $isnet = 1; last; }
77 my ($name, @ops) = ($isnet) ? ('network', keys %{$opers{$serv}})
78 : ('channel', map { $_->{nick} }
79 grep { $opers{$serv}{$_->{nick}} }
82 print $ph 'IRC operators on this '.$name." : \002@ops\n";
84 print $ph 'No IRC operators on this '.$name."\n";
88 help_text => 'OPSCAN, scan for IRC operators in the current channel'
91 $ph = new Xchat::XPI name => 'Operators',
93 desc => 'IRC operators scanner',
94 author => 'Vincent Pit (VPIT)',
95 email => 'perl@profvince.com',
96 url => 'http://www.profvince.com',
97 unload => sub { undef %opers; };