Pages : 1
#1 Le 27/10/2007, à 15:40
- vilraleur
Script Perl sous Xchat
J'essaye de me reprendre un script de blacklist sous Xchat2
celui ci
#!/usr/bin/perl -w
#
# S_list - by madragoran - madragoran@avendesora.net - 2002
#
# A simple shitlist script.
#
# By default, puts the shitlist file into ~/.xchat/
#
#
IRC::register("shitlist","1.5","","");
IRC::add_command_handler("addshit","addshit_command"); # Add lamer to shitlist
IRC::add_command_handler("ks","ks_command"); # Add to shitlist, then kick the lamer.
IRC::add_command_handler("unshit","unshit_command"); # Remove someone from shitlist
IRC::add_command_handler("shitlist","shitlist_command"); # List the lamers in the shitlist
IRC::add_message_handler("JOIN","join_handler"); # Check nicks joining against shitlist
# Open shitlist if there is one and load it into an array.
open ( LIST,'<.xchat/shitlist' )
or IRC::print("\0034***\t\002\00315No shitlist found.\n");
chomp( @shit = <LIST> );
close LIST;
# Look at who is joining and check it against the list.
sub join_handler {
my $blah = $_[0];
$_ = $blah;
( $nick, $user, $host, $hook, $channel ) = (/:(\S+)!(\S+)\@(\S+)\s(\w+)\s:(.*)/);
my $usermask = $nick . "!" . $user . "@" . $host; # Put these back together for list check
if ( @shit) {
foreach $item ( @shit ) {
$item =~ /(.*)::(.*):::/;
$list_mask = $1;
$list_reason = $2;
$list_mask =~ s/\*/\.\*/go;
if ( $usermask =~ /$list_mask/i ) {
IRC::send_raw( "KICK $channel $nick :$list_reason\r\n" );
}
}
}
return 0;
}
# add host to shitlist - usage: /addshit <host> <reason>
# The host you add can have * wildcards in it where necessary, ie, *!*lamer@*.aol.com
sub addshit_command {
chomp( my $lamer = $_[0] );
$_ = $lamer;
( $l_mask, $l_reason ) = (/\s*(\S+)\s+(.*)/);
$l_entry = $l_mask . "::" . $l_reason . ":::";
push( @shit, $l_entry );
open LIST, ">>.xchat/shitlist";
print LIST "$l_entry\n";
close LIST;
IRC::print("\0034***\t\00315Lamer with hostmask \002\0034$l_mask \002\00315has been shitlisted.\n");
return 1;
}
# Kick and shitlist command - kicks nick after shitlisting their host - usage: /ks <nick> <host>
# I meant this to be used as a button or popup - so xchat does the work of getting the host.
# Just make a button that has /ks %s *!*@%h as the command.
# I also added a random kick reason thing...so you'll need to make a text file full of clever kicks
sub ks_command {
chomp(my $stuff = $_[0]);
$_ = $stuff;
( $nick, $host) = (/(\S+)\s(\S+)/);
# Random kick reason thingy - you don't have to use this...
# If you use it, you will have to make your own kicks.txt file.
# If you don't want to use it, just comment these next 3 lines, and define $reason= <reason>
open KICKS, '<.xchat/kicks.txt';
rand($.) <1 and ($reason=$_) while <KICKS>;
close KICKS;
# End of random kick reason section.
IRC::command( "/addshit $host $reason" );
my $channel = IRC::get_info(2);
IRC::send_raw( "KICK $channel $nick :$reason\r\n" );
return 1;
}
# Remove host from the current shitlist. Usage: /unshit <hostmask>
# Requires that you provide the hostmask - maybe I should let lamers be removed by number?
sub unshit_command {
chomp(my $umask = $_[0]);
@ARGV = '.xchat/shitlist' or IRC::print("Shitlist not found.\n");
$^I = "~";
while (<>) {
s/.*\Q$umask\E.*\n//;
print;
}
IRC::print("\0034***\t\002\0038$umask \002\00315removed from shitlist.\n");
open ( LIST, '<.xchat/shitlist' );
chomp(@shit = <LIST> ); # Reinitialize the array by rereading the file...not the best way?
close LIST;
return 1
}
# Display the current shitlist in it's own window.
sub shitlist_command {
if ( @shit ) {
IRC::command( "/query Shitlist" );
IRC::print_with_channel("\002\0038Current shitlist:\n","Shitlist","");
my $header = sprintf "%s%65s\n", "Hostmask", "Reason";
IRC::print_with_channel( "\00311$header", "Shitlist", "" );
foreach $lamer (@shit) {
if ( $lamer ) {
$lamer =~ /(.*)::(.*):::/;
my $output = sprintf "%s%50s\n", $1, $2;
IRC::print_with_channel( "\00315$output", "Shitlist", "" );
}
}
} else {
IRC::print( "\0038Shitlist is empty.\n" );
}
return 1;
}
IRC::print("\00311S-list ver 1.5 loaded\n");
Etant sous Xchat2 j'ai modifié les adresse exemple
open KICKS, '<.xchat/kicks.txt';--> Par --> open KICKS, '<.xchat2/kicks.txt';
Vu que je suis sous Undernet je voudrait directement envoyé la commande a des bots
J'ai donc remplacer
IRC::send_raw( "KICK $channel $nick :$list_reason\r\n" ); --> Par -->IRC::command( "/msg x kick $channel $nick $list_reason\r\n" );
Mais ca passe pas .. j'ai ca comme commande
/mes x kick
j'arrive pas a récup les nick/host de ma list ...
Dernière modification par vilraleur (Le 27/10/2007, à 15:41)
Petit ! Méchant ! Médiocre !
Vilraleur
Tant qu'il râle c'est qu'il est pas mort
Hors ligne
Pages : 1