diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-15 20:19:02 +0000 |
commit | 03929dac2a29664878d2c971648a4fe1fb698462 (patch) | |
tree | 02c5e2b3e006234aa29545f7a93a1ce01b291a8b /scripts/rk.pl | |
parent | Initial commit. (diff) | |
download | irssi-scripts-upstream/20231031.tar.xz irssi-scripts-upstream/20231031.zip |
Adding upstream version 20231031.upstream/20231031upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'scripts/rk.pl')
-rw-r--r-- | scripts/rk.pl | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/scripts/rk.pl b/scripts/rk.pl new file mode 100644 index 0000000..204ad61 --- /dev/null +++ b/scripts/rk.pl @@ -0,0 +1,53 @@ +# rk.pl/Irssi/fahren@bochnia.pl + +use Irssi 20020300; +use strict; + +use vars qw($VERSION %IRSSI); +$VERSION = "0.9"; +%IRSSI = ( + authors => "Maciek \'fahren\' Freudenheim", + contact => "fahren\@bochnia.pl", + name => "Random kicker", + description => "/RK [-o | -l | -a] - kicks random nick from ops | lusers | all on channel", + license => "GNU GPLv2 or later", + changed => "Fri Mar 15 15:09:42 CET 2002" +); + +sub cmd_rk { + my ($args, $server, $chan) = @_; + + unless ($chan && $chan->{type} eq "CHANNEL" && $chan->{chanop}) { + Irssi::print("%R>>%n You aren't opped / You don't have active channel :/"); + return; + } + + my @data = split(/ /, $args); + my ($rk, @nicks); + $rk = 0; + + while ($_ = shift(@data)) { + /^-a$/ and $rk = 2, next; + /^-o$/ and $rk = 1, next; + /^-l$/ and $rk = 0, next; + } + + my $channel = $chan->{name}; + + for my $hash ($chan->nicks()) { + unless ($rk) { + next if $hash->{op}; + } elsif ($rk eq 1 && !$hash->{op}) {next}; + + next if ($hash->{nick} eq $server->{nick}); + + push @nicks, $hash; + } + + my $nnum = scalar(@nicks); + my $victim = $nicks[rand($nnum)]->{nick}; + + $server->send_raw("KICK $channel $victim :\002Random Kick\002"); +} + +Irssi::command_bind('rk', 'cmd_rk'); |