html/rk.pl


   1 # rk.pl/Irssi/fahren@bochnia.pl
   2 
   3 use Irssi 20020300;
   4 use strict;
   5 
   6 use vars qw($VERSION %IRSSI);
   7 $VERSION = "0.9";
   8 %IRSSI = (
   9         authors         => "Maciek \'fahren\' Freudenheim",
  10         contact         => "fahren\@bochnia.pl",
  11         name            => "Random kicker",
  12         description     => "/RK [-o | -l | -a] - kicks random nick from ops | lusers | all on channel",
  13         license         => "GNU GPLv2 or later",
  14         changed         => "Fri Mar 15 15:09:42 CET 2002"
  15 );
  16 
  17 sub cmd_rk {
  18 	my ($args, $server, $chan) = @_;
  19 
  20 	unless ($chan && $chan->{type} eq "CHANNEL" && $chan->{chanop}) {
  21 		Irssi::print("%R>>%n You aren't opped / You don't have active channel :/");	
  22 		return;
  23 	}
  24 
  25 	my @data = split(/ /, $args);
  26 	my ($rk, @nicks);
  27 	$rk = 0;
  28 
  29 	while ($_ = shift(@data)) {
  30 		/^-a$/ and $rk = 2, next;
  31 		/^-o$/ and $rk = 1, next;
  32 		/^-l$/ and $rk = 0, next;
  33 	}
  34 
  35 	my $channel = $chan->{name};
  36 	
  37 	for my $hash ($chan->nicks()) {
  38 		unless ($rk) {
  39 			next if $hash->{op};	
  40 		} elsif ($rk eq 1 && !$hash->{op}) {next};
  41 
  42 		next if ($hash->{nick} eq $server->{nick});
  43 
  44 		push @nicks, $hash;	
  45 	}
  46 
  47 	my $nnum = scalar(@nicks);
  48 	my $victim = $nicks[rand($nnum)]->{nick};
  49 	
  50 	$server->send_raw("KICK $channel $victim :\002Random Kick\002");
  51 }
  52 
  53 Irssi::command_bind('rk', 'cmd_rk');