#!/usr/bin/perl
### Xchat registers and hooks.
Xchat::register("Zack's Brag Script", "1.0", "Zack's /brag script.", "");
Xchat::hook_command("brag", "power_main");
use warnings;
use strict;
### Main routine.
sub power_main {
my $opped = my $whole = my $znetworks = my $oppedchans = my $hoppedchans = my $voppedchans = my $wholechannels = 0;
my $oldcontext = Xchat::get_context();
my @channels = Xchat::get_list('channels');
foreach my $temp (@channels){
my $type = $temp->{'type'};
my @id = $temp->{'id'};
if($type == 1){
$znetworks++;
} elsif($type == 2){
my $chan = $temp->{'channel'};
Xchat::set_context("$chan");
my $userinfo = Xchat::user_info();
if($userinfo->{'prefix'} =~ /^[~&@\!]$/){
my $users = Xchat::get_list('users');
$oppedchans++;
$wholechannels++;
$opped = $opped+$users;
$whole = $whole+$users;
} elsif($userinfo->{'prefix'} =~ /^[%\!]$/){
my $husers = Xchat::get_list('users');
$hoppedchans++;
$wholechannels++;
$opped = $opped+$husers;
$whole = $whole+$husers;
} elsif($userinfo->{'prefix'} =~ /^[+\!]$/){
my $vusers = Xchat::get_list('users');
$voppedchans++;
$wholechannels++;
$whole = $whole+$vusers;
} else {
my $uopusers = Xchat::get_list('users');
$wholechannels++;
$whole = $whole+$uopusers;
}
}
}
Xchat::set_context("$oldcontext");
Xchat::command("say I am on $wholechannels channels, across $znetworks networks. I have 0 olines, $oppedchans ops, $hoppedchans halfops and $voppedchans voices. I have non-abusive power over $opped people.");
return 1;
}