#!/usr/bin/perl -w # Banword. Ver 0.1. # This is a perl script for xchat by cancan@evhr.net # Put this script in your home directory and do a /load banword.pl in xchat # With xchat 0.5.3 you can put this script il your ~/.xchat and it will # by autoloaded (cool stuff) IRC::add_message_handler("PRIVMSG", "kickword"); IRC::add_command_handler("savewd", "saveword"); IRC::add_command_handler("addwd", "addword"); IRC::add_command_handler("delwd", "delword"); IRC::add_command_handler("listwd", "listword"); IRC::add_command_handler("helpwd", "helpword"); # WARNING : Edit this line, don't forget the / behind your directory $homepath = "/home/myhome/"; @kickwords=@nothing; # Loading the banword file if (open(BANWORD,$homepath.".banword")) { output ("\002 Loading the Ban Word file\002"); $list = ""; $list = ; @kickwords = split('\n',$list); close(BANWORD); } else { output("\002 Ban Word File not found, maybe you haven't one ;o)\002"); } sub kickword { my $line = shift(@_); $line =~ /:(.*)!(\S+) PRIVMSG (.*) :(.*)/i; $motnick = $1; $motchan = $3; @mots = split(' ',$4); foreach $testmots (@mots) { $mots3 = stripn(" ".$testmots." "); foreach $acompar (@kickwords){ @testword = split(':::',$acompar); $testchanwd = $testword[0]; $testwordwd = $testword[1]; if ($mots3 =~ $testwordwd && $testchanwd =~ $motchan) { $motkick = stripn(" Mot_interdit_:_\002\0034".$testmots."\003\002"); IRC::command "/raw KICK $motchan $motnick $motkick"; output ("\002 KICK $motchan $motnick $motkick\002"); return 1; } } } return 0; } sub helpword { output("\002 Commands are : \0034addwd\003 \002"); output("\002 adds a unauthorise word to the channel\002"); output("\002 \0034delwd\003 \002"); output("\002 dels a unauthorise word to the channel\002"); output("\002 \0034listwd\003 list the unautorised words\002"); output("\002 \0034savewd\003 save the unautorised words\002"); output("\002 \0034helpwd\003 this help text\002"); return 1; } sub listword { output("\002 List of all the unauthorised words\002"); output("\002------------------------------------\002"); foreach $listword (@kickwords) { $listword =~ /(.*):::(.*):::/i; output(" Channel : \002$1\002 unauthorised word : \002\0034$2\003\002"); } return 1; } sub saveword { if (!(open(BANWORD,">".$homepath.".banword"))) { output ("\002 Couldn't open the Ban word file !!!!!!!!!!!\002"); } else { foreach $lineec (@kickwords) { print BANWORD ("$lineec\n"); } close(BANWORD); output ("\002 Ban Word file saved\002"); return 1; } } sub addword { my $lineword = shift(@_); @newword = split(' ',$lineword); $newchanword = $newword[0]; $newwordword = $newword[1]; if (!($newchanword =~ /\S+/ && $newwordword =~ /\S+/ )) { output("\002 Enter channel and word, such as #linux billgates\002"); return 1; } $mots3 = stripn(" ".$newwordword." "); push @kickwords, ($newchanword.":::".$mots3.":::"); output("\002 Word \0034$newwordword\003 added for channel \0034$newchanword\003\002"); return 1; } sub delword { my $lineword = shift(@_); @newword = split(' ',$lineword); $newchanword = $newword[0]; $newwordword = $newword[1]; if (!($newchanword =~ /\S+/ && $newwordword =~ /\S+/ )) { output("\002 Enter channel and word, such as #linux billgates\002"); return 1; } $mots3 = stripn(" ".$newwordword." "); @holdin=""; pop(@holdin); unless (open(BANWORD, ">".$homepath.".banword")) { output("\002Couldn't open output file .banword!\002"); return 1; } foreach $acompar (@kickwords){ @testword = split(':::',$acompar); $testchanwd = $testword[0]; $testwordwd = $testword[1]; if (!($mots3 =~ $testwordwd && $testchanwd =~ $newchanword)) { print BANWORD ("$acompar\n"); push @holdin, $acompar; } } @kickwords = @holdin; close(BANWORD); output("\002 Word \0034$newwordword\003 deleted for channel \0034$newchanword\003\002"); }