| Uutiset | Koodikirjasto | Wiki | Keskustelut | FAQ | Info |
Quitmsgpunish (Irssi)Tuxe 23.10.05 12:09 Kickii tai kickbannaa seuraavan joinauskerran jälkeen henkilöt joilla oli värejä tai muuta roskaa quittimessussa.
use strict; use vars qw($VERSION %IRSSI); use Irssi; $VERSION = '20051023'; %IRSSI = ( authors => 'Tuomo Lempiäinen', contact => 'Tuxe@IRCnet, tuomo@lempiainen.net', name => 'quitmsgpunish', description => 'Kicks and optionally bans lamers who have mirc colors, '. 'blinking or nnscript/bafescript crap in their quit message.', license => 'GPL', url => 'http://lempiainen.net', ); sub check_quit_msg { my ($server, $nick, $address, $reason) = @_; #punish if quit message includes crap if ($reason =~ /(BaFeScript|NoNameScript|\x1b\[5m|\x3|\x6)/) { punish($nick, $address); } #remove from punish list if quit message was ok elsif (is_punished($nick, $address)) { unpunish($nick, $address); } } sub punish { my ($nick, $address) = @_; #add to punish list if user isn't already there if (!is_punished($nick, $address)) { my $file = Irssi::get_irssi_dir().'/quitmsgpunish.dat'; open(FILE, ">>$file"); print FILE "$nick!$address\n"; close(FILE); } } sub is_punished { my ($nick, $address) = @_; my $file = Irssi::get_irssi_dir().'/quitmsgpunish.dat'; open(FILE, $file); my @lamers = <FILE>; close(FILE); foreach my $lamer (@lamers) { #check if given nick and address match an entry of punish list if ($lamer eq $nick.'!'.$address."\n") { return 1; } } return 0; } sub unpunish { my ($nick, $address) = @_; my $file = Irssi::get_irssi_dir().'/quitmsgpunish.dat'; open(FILE, ">$file"); my @lamers = <FILE>; foreach my $lamer (@lamers) { #keep in the punish list if nick or address doesn't match if ($lamer ne $nick.'!'.$address."\n") { print FILE $lamer; } } close(FILE); } sub join { my ($server, $channel, $nick, $address) = @_; #check if the channel is in the list of allowed channels my @channels = split(/ /, Irssi::settings_get_str('quitmsgpunish_channels')); my $allowed = 0; foreach my $chan (@channels) { if ($chan eq $channel) { $allowed = 1; } } if (is_punished($nick, $address) && $allowed) { #set ban if desired if (Irssi::settings_get_bool('quitmsgpunish_ban')) { $server->command("mode $channel +b $nick!$address"); } #kick the lamer $server->command("kick $channel $nick ". Irssi::settings_get_str('quitmsgpunish_message')); #remove user from the punish list once he got kicked unpunish($nick, $address); } } sub help { print "%9quitmsgpunish%9 v$VERSION © 2005 Tuomo Lempiäinen aka Tuxe Settings: %9quitmsgpunish_ban%9: if enabled, kickban the user istead of just kicking %9quitmsgpunish_message%9: kick reason %9quitmsgpunish_channels%9: space-separated list of channels where ". "quitmsgpunish is enabled"; } Irssi::command_bind('quitmsgpunish', 'help'); Irssi::signal_add('message quit', 'check_quit_msg'); Irssi::signal_add('message join', 'join'); Irssi::settings_add_bool('quitmsgpunish', 'quitmsgpunish_ban', 1); Irssi::settings_add_str('quitmsgpunish', 'quitmsgpunish_message', 'Fix your quit message, n00b!'); Irssi::settings_add_str('quitmsgpunish', 'quitmsgpunish_channels', ''); Irssi::print("quitmsgpunish loaded, type '/quitmsgpunish' for help"); |
![]() Haku
|