1# AKILL a specified nick, either with the defined reason or with something given 2# in the command 3# 4# (C) 2006 by Joerg Jaspert <joerg@debian.org> 5# (C) 2007 by Christoph Berg <cb@df7cb.de> 6# 7# This program is free software; you can redistribute it and/or modify 8# it under the terms of the GNU General Public License as published by 9# the Free Software Foundation; either version 2 of the License, or 10# (at your option) any later version. 11# 12# This program is distributed in the hope that it will be useful, 13# but WITHOUT ANY WARRANTY; without even the implied warranty of 14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15# GNU General Public License for more details. 16# 17# You should have received a copy of the GNU General Public License 18# along with this script; if not, write to the Free Software 19# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 20 21 22use strict; 23use Irssi; 24 25use vars qw($VERSION %IRSSI); 26 27$VERSION = '0.2'; 28%IRSSI = ( 29 authors => 'Joerg Jaspert', 30 contact => 'joerg@debian.org', 31 name => 'akilluser', 32 description => 'AKILLS a nick', 33 license => 'GPL v2 (and no later)', 34); 35 36######################################################################## 37# Kill it 38 39sub akill_nick { 40 my ($arg, $server, $channel) = @_; 41 42 $arg =~ /(\S+)\s?(.*)?/; 43 my ($target, $reason) = ($1, $2); 44 my ($user, $host); 45 46 if ($target =~ /(.+)@(.+)/) { 47 ($user, $host) = ($1, $2); 48 } else { 49 if (!$channel) { 50 Irssi::print("Not joined to a channel"); 51 return; 52 } 53 my $nickh = $channel->nick_find($target); 54 if (!$nickh->{host}) { 55 Irssi::print("User $target not found on $channel->{name}"); 56 return; 57 } 58 if ($server->masks_match(Irssi::settings_get_str('akill_exempt'), $target, $nickh->{host})) { 59 Irssi::print("Not AKILLing an akill-exempt user"); 60 return; 61 } 62 $nickh->{host} =~ /(\S+)@(\S+)/; 63 ($user, $host) = ("*", $2); 64 } 65 66 if ("$user$host" !~ /[\w\d]/) { 67 Irssi::print("AKILLing $user\@$host looks insane"); 68 return; 69 } 70 71 if (length($reason) < 2) { 72 $reason = Irssi::settings_get_str('akill_reason'); 73 } 74 if ($reason !~ /\@oftc\.net/) { 75 $reason .= " " . Irssi::settings_get_str('akill_trailer'); 76 } 77 78 my $window = Irssi::active_win(); 79 $window->print("AKILLed $target ($user\@$host) with \"$reason\""); 80 $server->command("quote os akill add $user\@$host $reason"); 81} 82 83 84######################################################################## 85# ---------- Do the startup tasks ---------- 86 87# Add the settings 88Irssi::settings_add_str("akilluser.pl", "akill_reason", 'This host violated network policy.'); 89Irssi::settings_add_str("akilluser.pl", "akill_trailer", 'Mail support@oftc.net if you think this is in error.'); 90Irssi::settings_add_str("akilluser.pl", "akill_exempt", '*!*@*.sponsor.oftc.net *!*@*.advisor.oftc.net *!*@*.netrep.oftc.net *!*@*.netop.oftc.net *!*@*.noc.oftc.net *!*@*.ombudsman.oftc.net *!*@*.chair.oftc.net'); 91 92Irssi::command_bind('akill', 'akill_nick'); 93