[Résolu] erreur sur un tcl
#1
Bonjour j'essaye de faire un tcl pour annoncer des pubs sur plusieurs salons ça marche mais j'ai une erreur
voici le code tcl:
Code :
setudef flag Annonce
namespace eval ::SalonAnnonce {
   # Commande pour activer sur un chan
   variable onCmd "!annonce.on"
   # Commande pour désactiver sur un chan
   variable offCmd "!annonce.off"
   # Flags requis pour activer ou désactiver
   variable cmdFlags o
}

bind pub $::SalonAnnonce::cmdFlags $::SalonAnnonce::onCmd ::SalonAnnonce::pubOn
bind pub $::SalonAnnonce::cmdFlags $::SalonAnnonce::offCmd ::SalonAnnonce::pubOff

#
proc SalonAnnonce::pubOn {nick host hand chan arg} {
       if {[channel get $chan Annonce] == 0} {
               channel set $chan +Annonce
               puthelp "PRIVMSG $chan :\00314Activation des Annonces sur\00302 $chan" } {
               puthelp "PRIVMSG $chan :\00314Les Annonces sont déjà activées sur\00302 $chan"
       }
}
     
#
proc SalonAnnonce::pubOff {nick host hand chan arg} {
       if {[channel get $chan Annonce] == 1} {
               channel set $chan -Annonce
               puthelp "PRIVMSG $chan :\00314Désactivation des Annonces sur\00302 $chan" } {
               puthelp "PRIVMSG $chan :\00314Les Annonces sont déjà désactivées sur\00302 $chan"
       }
}


bind cron - "*/5 * * * *" advertise

set advertisetext {
"annonce1"
"annonce2"
"annonce3"
"annonce4"
}

proc advertise { nick uhost hand chan arg } {
global advertisetext
if {[channel get $chan Annonce]} {
set msg_s [lindex $::advertisetext [expr {int(rand() * [llength $::advertisetext])}]]
putserv "privmsg $chan : $msg_s"
}
}

et mon erreur
Code :
Tcl error [advertise]: no such channel record

Merci
Répondre Avertir
#2
Ta procédure advertise n'est pas bonne. Elle est déclenchée par un bind cron donc elle ne reçoit pas un canal en argument.
Il faudrait que tu fasses une boucle sur les canaux connus de l'eggdrop pour tester le flag et annoncer ou pas:
tcl
proc advertise {n h d m y} {
   foreach chan [channels] {
      if {[channel get $chan Annonce]} {
         set msg_s [lindex $::advertisetext [expr {int(rand() * [llength $::advertisetext])}]]
         putserv "privmsg $chan : $msg_s"
      }
   }
}


Répondre
#3
Merci CrazyCat ça marche niquel avec un foreach j'avais essayé mais surement pas comme il fallait puisque j'avais les annonces en double et l'erreur avec.
Mais tout est rentré dans l'ordre encore merci Smile
Répondre Avertir
#4
Message sans intérêt que je post ici, mais je trouve le code plutôt pas mal et intéressant. en faite je parle surtout de :
tcl
[expr {int(rand() * [llength $::advertisetext])}]]


Répondre Avertir


Atteindre :


Utilisateur(s) parcourant ce sujet : 1 visiteur(s)
Tchat 100% gratuit -Discutez en toute liberté