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