html/ownage.pl
1 # /OWNAGE [<output to channel>]
2 # shows how many channels you're joined and how many in them you're op, and
3 # how many nicks are in those channels (not including you)
4
5 use strict;
6 use vars qw($VERSION %IRSSI);
7
8 use Irssi;
9 $VERSION = '20071209';
10 %IRSSI = (
11 authors => '',
12 contact => '',
13 name => '',
14 description => '',
15 license => '',
16 commands => 'ownage',
17 );
18
19 sub cmd_ownage {
20 my $chans = 0;
21 my $opchans = 0;
22 my $nicks = 0;
23 my $opnicks = 0;
24
25 foreach my $channel ( Irssi::channels() ) {
26 $chans++;
27 if ( $channel->{chanop} ) {
28 $opchans++;
29 my @channicks = $channel->nicks();
30 $nicks += ( scalar @channicks ) - 1;
31
32 $opnicks--; # don't count youself
33 foreach my $nick (@channicks) {
34 $opnicks++ if $nick->{op};
35 }
36 }
37 }
38 my ( undef, undef, $dest ) = @_;
39 my $text =
40 "@" . "$opchans / $chans : $nicks nicks (of which $opnicks are ops)";
41 if ( $dest && ( $dest->{type} eq "CHANNEL" || $dest->{type} eq "QUERY" ) ) {
42 $dest->command("msg $dest->{name} $text");
43 }
44 else {
45 Irssi::print $text, MSGLEVEL_CLIENTCRAP;
46 }
47 }
48
49 Irssi::command_bind( 'ownage', 'cmd_ownage' );