#1 Le 04/09/2013, à 10:24
- Moya
Perl - Condition qui ne fonctionne pas - Xchat
Bonjour
Je ne suis pas du tout pro en Perl, mais j'ai des bases
J'ai codé ça :
#!/bin/perl -w
Xchat::hook_command("addwhite", cmd_adduser);
sub cmd_adduser{
my $nick = $_[0][1];
my $nickinfo = Xchat::user_info($nick);
my $nickhost = $nickinfo->{host};
my $whitelist = "";
open(FICLIST, "<".$homedir."\\whitelist");
@users = <FICLIST>;
my $i = 0;
while (defined( $users[$i] )) {
chomp @users[$i];
if($nickhost==@users[$i]){
Xchat::print("***-\00305$nick-\00309".length(@users[$i])."-@users[$i]-\00302".length($nickhost)."-$nickhost-\017***", $netw, $serv);
Xchat::print("*** \00309$nick est déjà dans la liste blanche ! \017***", $netw, $serv);
$whitelist = "ok";
}
$i += 1
}
close(FICLIST);
if(!$whitelist){
# Xchat::print("*** \00305$whitelist \00309$nickhost !\017\n", $netw, $serv);
if($nickhost){
Xchat::print("*** \00305$nick \00309Ajouté(e) à la liste blanche !\017\n", $netw, $serv);
open(FICLIST, ">>".$homedir."\\whitelist");
print ( FICLIST "$nickhost\n" );
close(FICLIST);
} elsif(!$nickhost){
Xchat::print("*** \00305Aucun host trouver pour $nick\017\n", $netw, $serv);
}
}
$whitelist = "";
return Xchat::EAT_NONE;
}
Et en sortie j'ai ça :
***-Diablotine-15-CroC@CroC.OdilE-38-Virginie@D0A4F1C8.CBA07B7E.88669293.IP-***
*** Diablotine est déjà dans la liste blanche ! ***
***-Diablotine-17-Rygel@Bio.Dominar-38-Virginie@D0A4F1C8.CBA07B7E.88669293.IP-***
*** Diablotine est déjà dans la liste blanche ! ***
* addwhite :Unknown command
Voila je comprend pas ce que j'ai mal fait
Merci
Hors ligne
#2 Le 09/09/2013, à 19:30
- JoelS
Re : Perl - Condition qui ne fonctionne pas - Xchat
Excuses moi, mais comment tu fais marcher ça sous ubuntu ?
Le package Xchat.pm n'existe pas dans le CPAN. Il n'est pas chargé dans ton script Perl.
Hors ligne