Bienvenue sur les archives forum du Parti Pirate


Le Parti Pirate refond complètement son forum et a migré vers un outil plus moderne et performant, Discourse !
Retrouvez nous ici : https://discourse.partipirate.org

Hook qui ne fonctionne pas

discu.2014
Moya
Messages : 2
Inscription : sam. 21 déc. 2013, 20:39

Hook qui ne fonctionne pas

Messagepar Moya » jeu. 29 mai 2014, 13:14

Bonjour, j'ai fait un petit script Perl pour Xchat 2 (tester sous Hexchat) qui me pose probleme :

Code : Tout sélectionner

#!/bin/perl -w
#
use POSIX qw/strftime/;
#
my $vert = "\00303";
my $violet = "\00306";
my $rouge = "\00304";
my $bleue = "\00302";
my $jaune = "\00308";
my $gras = "\cB";
my $norm = "\017";
my $temp = "";
my $EnTete = "$rouge-$vert Xchat $rouge- \ci";
my $homedir = Xchat::get_info(xchatdir);
#
my $Hook_start = Xchat::hook_command( 'go' , 'Start' );
my $Hook_stop = "";
my $time = 0;
my $time2 = 0;
#
&Init();
#
sub Init {
   if (!open(WRITE,$homedir."\\timer.txt")) {
      open(WRITE,">>".$homedir."\\timer.txt");
      close(WRITE);
   }
}
sub Start {
   Xchat::unhook( $Hook_start );
   $Hook_start = "";
   if ($Hook_stop eq "") {
      $Hook_stop = Xchat::hook_command( 'stop' , 'halt' );
   } else {
      Xchat::prnt("Erreur Hook stop");
   }
   $time = strftime("%M%S", localtime());
   Xchat::command("SAY $time");
   # return Xchat::EAT_ALL
}
sub halt {
   Xchat::unhook( $Hook_stop );
   $Hook_stop = "";
   if ($Hook_start eq "") {
      $Hook_start = Xchat::hook_command( 'go' , 'Start' );
      Xchat::prnt("$Hook_start");
   } else {
      Xchat::prnt("Erreur Hook start");
   }
   $time2 = strftime("%M%S", localtime());
   $result = $time2 - $time;
   my $date = strftime("%d/%m/%Y", localtime());
   my $write = $date." ".$result."\n";
   open(FICDATA,">".$homedir."\\timer.txt");
   print(FICDATA $write);
   close(FICDATA);
   Xchat::command("SAY $date $result");
   $time = 0;
   $time2 = 0;
   # return Xchat::EAT_XCHAT
}
#


Le $Hook_stop = Xchat::hook_command( 'stop' , 'halt' ); ne semble pas fonctionner alors que j'utilise ce principe dans d'autre script et ça fonctionne tres bien.

Le plus bizarre c'est que apres un /help je vois bien la commande 'stop' ...

Si quelqu'un a une idée. Merci [:)]

Revenir vers « Archive 2014 »

Qui est en ligne ?

Utilisateurs parcourant ce forum : Aucun utilisateur inscrit et 2 invités