use strict; use Irssi; use Irssi::Irc; use vars qw($VERSION %IRSSI); $VERSION = "0.2"; %IRSSI = ( authors => 'Dan Boger, Alex Pounds', contact => 'zigdon@gmail.com', name => 'shutup', description => 'Shut up annoying users', license => 'GNU GPL v2', url => 'http://peeron.com', changed => 'Thu Jun 5 14:57:04 PDT 2008', ); sub cmd_shutup { my ($data, $server, $win) = @_; cmd_specialban($data, $server, $win, 'q'); } sub cmd_nonickchange { my ($data, $server, $win) = @_; cmd_specialban($data, $server, $win, 'n'); } sub cmd_specialban { my ($data, $server, $win, $type) = @_; $data =~ s/^\s+//; $data =~ s/\s.*//; unless ($server and $server->{connected}) { Irssi::active_win()->print("Not connected to server!"); return; } unless ($win and $win->{type} eq 'CHANNEL') { Irssi::active_win()->print("Can't ban people out of channel!"); return; } my $channel = $server->channel_find($win->{name}); my $nick = $channel->nick_find($data); my $timeout = 60; if ($type eq 'q') { $timeout = Irssi::settings_get_int("shutup_length") || 300; } elsif ($type eq 'n') { $timeout = Irssi::settings_get_int("nonickchange_length") || 1800; } if ($nick) { if ($type eq 'q') { Irssi::command("/msg $win->{name} Shut up, $data."); } else { Irssi::command("/msg $win->{name} Stop that, $data."); } $server->send_raw("mode $win->{name} +b ~$type:$nick->{host}"); Irssi::timeout_add_once( $timeout*1000, sub { $server->send_raw("mode $win->{name} -b ~$type:$nick->{host}"); }, ""); if ($type eq 'q') { Irssi::active_win()->print("Shutting up $data for $timeout seconds."); } elsif ($type eq 'n') { Irssi::active_win()->print("Stopping $data from changing nicks for $timeout seconds."); } } else { Irssi::active_win()->print("Can't find $data in $channel->{name}."); return; } } Irssi::settings_add_int("misc", "shutup_length", 300); Irssi::settings_add_int("misc", "nonickchange_length", 1800); Irssi::command_bind("shutup", "cmd_shutup"); Irssi::command_bind("nochange", "cmd_nonickchange");