trivia.tcl [résolu]
#1
bonjour voici le petit bug

Tcl error [tgstart]: can't read "tgmaxhintcurrent": no such variable

et j'ai que modifier le rep du questionnaire et les flag o|o pour le !start

merci
Répondre Avertir
#2
TCL
################################################################################
#VEUILLEZ adapter les arrangements a vos besoins avant de rehashing votre BOT! #
################################################################################

#  indiquer dans quel repertoire devra se trouver votre base de donnée contenant les questions/réponses.
set tgqdb "/home/eggdrop/databases/trivia.questions"

#  indiquer quel séparateur distinguera les questions des réponses dans la base de données. Dans le cas présent il s'agit d'un |
set tgqdbsep "|"

#  ce paramètre permet de dire si les lignes de la base de donnée contenant les questions est de la forme :
#  . Réponse seperateur question (dans ce cas mettre la variable à 0)
#  ou
#  . Question séparateur réponse (dans ce cas metre la variable à 1)
set tgqdbquestionfirst 1

#  Ce paramètre permettra de définir dans quel répertoire se situe le fichier contenant les scores du jeu.
#  Si ce fichier existe pas il sera crée automatiquement.
set tgscf "/home/eggdrop/databases/trivia.scores"

#  Ce paramètre permet de définir comment vous serez averti en cas d'erreur dans une question :
#  . Mettre à 1 si vous désirez être averti par email (et si votre shell peut le faire)
#  ou
#  . Mettre à 0 si vous voulez que les erreurs soient stocker dans un fichier.
set tgerrmethod 1

#  C'est dans cette variable que vous mettrez dans quel répertoire
#  vous voulez stocker le fichier contenant les erreurs. (si tgerrmethod est à 0)
#  Si ce fichier n'existe pas il sera crée automatiquement.
set tgerrfil "/home/eggdrop/databases/trivia.errors"

#  Dans cette variable vous mettrez votre email. Ceci permettra au robot
#  d'envoyer un rapport sur les erreurs éventuelles. (si tgerrmethod est à 1)
set tgerremail "crazycat@c-p-f.org"

#  Ici vous définirez ou est ce que le robot créera un fichier temporaire
#  contenant un rapport sur les envois des erreurs PAR EMAIL.
set tgerrmailtmp "/tmp"

#  Ici vous définirez le Répertoire + nom de la page Web que génèrera le robot !
#  En effet, le robot génère une page web en temps réèl avec les scores.
#  Si ce fichier n'existe pas il sera crée automatiquement.
set tghtmlfile "/home/eggdrop/public_html/quizz.html"

#  Cette variable permet de définir tout les combiens de temps la page HTML est rafraichi.
#  Mettre 0 pour désactivé la page HTML.
set tghtmlrefresh 20

#  Cette variable permet de définir quel style de fond sera utilisé sur la page web.
set tghtmlfont "verdana,helvetica,arial"

#  Cette variable permet de définir dans quel salon se déroulera le quizz.
set tgchan "#quizz"

#  Cette variable permet de définir combien de point seront donnés à un utilisateur
#  qui donne une bonne réponse.
set tgpointsperanswer 4

#  Cette variable définit le nombre max d'indice fournit pas le robot lors d'une question.
set tgmaxhint 3

#  Cette variable permet de définir si le robot montrera la question à chaque conseil (1)
#  ou seulement à la première (0).
set tgalwaysshowq 1

#  Cette variable permet de montrer (1) ou pas (0), les questions en lettres majuscules.
set tgcapsquestion 0

#  Cette variable permet de montrer (1) ou pas (0), les réponses en lettres majuscules.
set tgcapsanswer 0

#  Cette variable permet de montrer (1) ou pas (0), les conseils en lettres majuscules.
set tgcapshint 0

#  Cette variable permet de définir à partir de combien de réponse une personne se retrouvera
#  dites dans une 'série de bonnes réponses' (Mettre à 0 pour désactiver).
set tgstreakmin 3

#  Cette variable permet de définir à partir de combien de questions sans réponse le quizz
#  sera stoppé. (Si vous mettez 0, le quizz ne se stoppera que lorsqu'une personne autorisée fera !stop).
set tgmaxmissed 5

#  Cette variable permet de définir quel caractère remplacera la réponse lorsque le quizz posera la question.
set tghintchar "*"

#  Cette variable permet de définir combien de temps (en seconde) s'écoulera entre chaque conseils.
set tgtimehint 30

#  Permet de définir le temps (en seconde) qui s'écoulera entre le moment ou une bonne réponse a été donnée
#  ou un saut de question ET la prochaine question.
set tgtimenext 10

#  Cette variable permet de définir ce que dira le robot lors d'une bonne réponse.
set tgcongrats [list "Bravo" "Super" "Tres Bien" "C'est pas mal!" "Réussi" "Bonne réponse!" "Trouvé!" "Tu ne te serais pas dopé?"]

#  Cette variable permet de définir ce que dira le robot lorsque personne n'aura répondu correctement à une question.
set tgnobodygotit [list "Personne n'a trouvé..." "Y'a quelqu'un ?" "On va essayer de trouver plus simple..." "Euh? je joue avec des CM2 ?" "Mdr vous êtes nuls!" "On va pas aller loin ainsi!"]

#  Cette variable permet de définir ce que dira le robot lorsque l'on gagne plusieurs fois d'affilé.
set tgmulti [list "veut atteindre le podium" "a t-il prit des cachets ?" "Wowww ca va bien ?" "qu'est-ce qui t'arrive ?" "ne veut pas finir dernier sa c sur !"]

 
#  Cette variable permet de définir ce que dira le robot lorsque personne n'aura répondu à une question et l'arrivée de la prochaine question.
set tgtrythenextone [list "Peut etre la prochaine" "Une autre ...." "Peut etre celle ci..." "Suivante..." "Une autre!!!Une autre!!!..."]

#  Cette variable permet de calculer en combien de temps a été donné une bonne réponse. Mettre à 1 pour activer, 0 pour désactiver.
set tgtimeanswer 1

#  Cette variable permet de définir si le robot donnera la réponse si personne la trouve. Mettre à 0 pour cacher la réponse, à 1 pour la montrer.
set tgshowanswer 1

#  Cette variable permet de définir si le robot anoncera le score de la personne donnant une bonne réponse (0)
#  ou alors les scores de tout les joueurs présents sur le salon (1).
set tgshowallscores 1

#  Cette variable permet d'activé le gras (1) ou non (0) dans ses phrases.
set tgusebold 1

#  Mettre à 1 si vous voulez que le robot envoie les messages privés en pv, ou à 0 pour qu'ils les envoient en notice.
set tgpriv2msg 0

#  Cette variable permet de définir sur quel mot réagira le robot pour vous aider... dans ce cas là,
#  si vous envoyez en message privé au robot 'Qaide' , il vous enverra un message d'aide.
set tgcmdhelp "Qaide"

#  Commande permettant de lancer le quizz.
set tgcmdstart "!start"

#  Flag requiert pour lancer le quizz.
set tgflagsstart "-|-"

#  Commande permettant de stopper le quizz.
set tgcmdstop "!stop"

#  Flag requiert pour stopper le quizz.
set tgflagsstop "o|o"

#  Commande permettant de donné un indice à une question.
set tgcmdhint "!indice"

#  Flag requiert pour effectuer la commande pour obtenir un indice.
set tgflagshint "-|-"

#  Temps en seconde entre lequel la commande !indice est désactivé lorsque celle-ci est utilisée.
set tgtempnohint 10

#  Commande permettant de sauter une question.
set tgcmdskip "!saut"

#  Flag requiert pour pouvoir effectuer un saut de question.
set tgflagsskip "o|o"

#  Commande permettant de voir le Top10 !
set tgcmdtop10 "!top10"

#  Flag requiert pour pouvoir utiliser le top10.
set tgflagstop10 "-|-"

#  Commande permettant de mettre à zéro les scores (/msg botnick reset)
set tgcmdreset "reset"

#  Flag requiert pour pouvoir utiliser la commande reset.
set tgflagsreset "m|m"

#  Mettre à 1 pour utiliser le reset avec un pass (/msg quizz reset votre-pass),
#  à 0 sans pass (/msg quizz reset).
set tgresetreqpw 0

#  Cette commande permet de définir la commande pour voir les scores ( /msg botnick score ).
set tgcmdlookup "score"

#  Cette commande permet de définir la commande pour ciblé un score (/msg botnick place pseudo).
set tgcmdtarget "place"

#  Cette commande permet de définir la commande pour repporter une erreur (/msg botnick erreur).
set tgcmderror "erreur"

#  Cette commande permet de définir la commande pour connaitre les règles du salon (/msg botnick règles).
set tgcmdrules "règles"

#  cette variable permet de définir les règles du salon.
set tgrules "Aucune publicité, aucun blasphème, aucun harcelement des utilisateurs, aucuns scripts actifs et aucun flood.  Violez ces règles et vous vous verrez banni. Bon jeu :-)"

#  Nombre de minutes entre lequel la commande de report d'erreur est désactivée.
set tgerrremindtime 60

#  COULEURS

#  Voilà les codes couleurs utilisé sur Mirc:
#  00:blanc        01:noir        02:blue foncé   03:vert foncé
#  04:rouge        05:marron      06:pourpre      07:orange
#  08:jaune        09:vert clair  10:turquoise    11:cyan
#  12:bleu clair   13:magenta     14:gris foncé   15:vert clair
#
#  Il faut toujours spécifié le code couleurs avec 2 chiffres "01"
#  et non un seul "1".
#  Pour spécifié un fond mettre d'abord la couleur de texte,
#  une virgule et la couleur de fond exemple "00,04" (texte blanc
#  sur fond rouge).
#  Pour désactivé la couleur utilise "".
 
set tgcolourstart "03"        ;#Début du jeu.
set tgcolourstop "04"        ;#Fin du jeu.
set tgcolourskip "10"        ;#Question sauté.
set tgcolourerr "04"        ;#Quand report d'une erreur.
set tgcolourmiss "10"        ;#Personne n'a répondu à la question.
set tgcolourqhead "04"        ;#Titre de la question.
set tgcolourqbody "12"        ;#Couleur du texte de la question.
set tgcolourhint "03"        ;#Couleur de l'indice.
set tgcolourstrk "12"        ;#Personne dans une 'une série de bonne réponse'.
set tgcolourscr1 "04"        ;#Couleur de la personne en 1ere place.
set tgcolourscr2 "12"        ;#Couleur de la personne en 2nd place.
set tgcolourscr3 "03"        ;#Couleur de la personne en 3eme place.
set tgcolourrset "04"        ;#Quand les scores sont mises à 0.
set tgcolourstend "12"        ;#Fin d'une 'série de bonne réponse'.
set tgcolourmisc1 "06"        ;#Couleur diverse 1.
set tgcolourmisc2 "04"        ;#Couleur diverse 2.

 
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#                                                                         #
#   l'édition faite au delà de ce point est faite à votre propre risque!  #
#                                                                         #
# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
#Contrôles divers et initialisations des variables
set tgver "1.3.4"
set tgrel "release"
 
proc no_accent {code_text} {
   regsub -all é $code_text "e" code_text
   regsub -all è $code_text "e" code_text
   regsub -all ê $code_text "e" code_text
   regsub -all ï $code_text "i" code_text
   regsub -all ï $code_text "i" code_text
   regsub -all ù $code_text "u" code_text
   regsub -all ô $code_text "o" code_text
   regsub -all ç $code_text "c" code_text
   regsub -all à $code_text "a" code_text
   regsub -all â $code_text "a" code_text
   return $code_text
}
 
if {[info tclversion]<8.2} {
    putlog "\002[file tail [info script]]\002 chargement échoué: Pour utiliser ce script, votre eggdrop doit être compilé avec tcl 8.2 ou supérieur (recommandé: version stable)."
    return
}
if {$tgtimeanswer==1&&[info tclversion]<8.3} {
    putlog "\002[file tail [info script]]\002 warning: la synchronisation des réponses a été automatiquement neutralisée. Cette commande requiert tcl 8.3 ou supérieur."
    set tgtimeanswer 0
}
if {![info exists alltools_loaded]||$allt_version<205} {
    putlog "\002[file tail [info script]]\002 chargement échoué: charger alltools.tcl v1.14 ou supérieur (disponible avec un eggdrop 1.6.13 ou supérieur) avant d'essayer de charger ce tcl."
    return
}
if {[utimerexists tghtml]!=""} {killutimer $tghtmlrefreshtimer}
if {$tghtmlrefresh>0} {
    set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}
if {![file exists $tgqdb]} {
    putlog "\002[file tail [info script]]\002 chargement échoué: $tgqdb n'existe pas."
    return
}
if {[llength [split $tgchan]]!=1} {
    putlog "\002[file tail [info script]]\002 chargement échoué: trop de canaux indiqués."
    return
}
if {![info exists tgplaying]} {
    set ctcp-version "${ctcp-version} (avec trivia.tcl $tgver ($tgrel) par www.eggdrop.za.net)"
    set tgplaying 0
}
if {![info exists tghintnum]} {set tghintnum 0}
if {![info exists tgmissed]} {set tgmissed 0}

#Binds
bind pubm $tgflagsstart "$tgchan %$tgcmdstart" tgstart
bind pubm $tgflagsstop "$tgchan %$tgcmdstop" tgstop
proc tgbindhintcmd {} {
    global tgflagshint tgcmdhint
    bind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
proc tgunbindhintcmd {} {
    global tgflagshint tgcmdhint
    unbind pubm $tgflagshint "$::tgchan %$tgcmdhint" tgforcehint
}
tgbindhintcmd
bind pubm $tgflagsskip "$tgchan %$tgcmdskip" tgskip
bind pubm $tgflagstop10 "$tgchan %$tgcmdtop10" tgshowtop10
bind join -|- "$tgchan *" tgjoinmsg
bind msg - $tgcmdhelp tggivehelp
bind msg - $tgcmdlookup tgscorelookup
bind msg - $tgcmdtarget tgtargetlookup
bind msg - $tgcmderror tgerror
bind msg - $tgcmdrules tgrulesmsg
bind msg $tgflagsreset "$tgcmdreset" tgresetscores
bind kick - "$tgchan $botnick" tgbotgotkicked
bind evnt - disconnect-server tgbotgotdisconnected

#lancé le jeu s'il n'est pas en marche.
proc tgstart {nick host hand chan text} {
    global tgplaying tgstreak tgchan tgerrremindtime tgerrremindtimer tgmissed
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==0} {
            tggamemsg "[tgcolstart]Quizz démarré par $nick!"
            tgnextq
            set tgplaying 1
            set tgstreak 0
            set tgmissed 0
            set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
        }
    }
}

#arrête le jeu s'il fonctionne.
proc tgstop {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
    global tgerrremindtimer tgrebindhinttimer
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1} {
            tggamemsg "[tgcolstop]Quizz arreté par $nick!"
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
            set tgstreak 0
            set tgplaying 0
            catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
            if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
            if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
            if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
            if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
        }
    }
}

#donne un indice s'il y a actuellement une question à répondre.
proc tgforcehint {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak tgstreakmin
    global tgtempnohint tgmaxhintcurrent tghintnum tgrebindhinttimer tgtempnohint
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1&&[utimerexists tghint]!=""} {
            killutimer $tghinttimer
            tghint
            tgunbindhintcmd
            if {$tghintnum<$tgmaxhintcurrent} {
                set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
            }
        }
    }
}

#saute la question courante si on le demande.
proc tgskip {nick host hand chan text} {
    global tghinttimer tgnextqtimer tgplaying tgchan tgcurrentanswer tgstreak
    global tgstreakmin tgtimenext tgrebindhinttimer
    if {[strlwr $tgchan]==[strlwr $chan]} {
        if {$tgplaying==1&&[utimerexists tghint]!=""} {
            tggamemsg "[tgcolskip]Saut vers la prochaine question par [tgcolmisc2]$nick[tgcolskip] "
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin&&[strlwr [lindex [split $tgstreak ,] 0]]==[strlwr $nick]} {
                tgstreakend
                set tgstreak 0
            }
            catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
            killutimer $tghinttimer
            if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
            set tgnextqtimer [utimer $tgtimenext tgnextq]
        }
    }
}

#rappelle sur le canal comment rapporter des erreurs dans les questions/réponses
proc tgerrremind {} {
    global tgerrremindtimer tgerrremindtime botnick tgcmderror
    tggamemsg "[tgcolerr]Pour reporter les erreurs dans les questions/réponses, taper /msg $botnick $tgcmderror <numéro> \[description\]"
    set tgerrremindtimer [timer $tgerrremindtime tgerrremind]
}

#Arrete le quizz si le bot est kické
proc tgbotgotkicked {nick host hand chan targ text} {
    tgquietstop
}
#Arrete le quizz si le bot est déconnecté
proc tgbotgotdisconnected {disconnect-server} {
    tgquietstop
}

#arrête le jeu si plus sur le canal.
 
proc tgquietstop {} {
    global tgplaying tgstreak tgchan tgcurrentanswer tghinttimer tgnextqtimer tgerrremindtimer
    global tgrebindhinttimer
    if {$tgplaying==1} {
        set tgstreak 0
        set tgplaying 0
        catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
        if {[utimerexists tghint]!=""} {killutimer $tghinttimer}
        if {[utimerexists tgnextq]!=""} {killutimer $tgnextqtimer}
        if {[timerexists tgerrremind]!=""} {killtimer $tgerrremindtimer}
        if {[utimerexists tgrebindhinttimer]!=""} {killtimer $tgrebindhinttimer}
    }
}

#lit la base de données de question.
proc tgreadqdb {} {
    global tgqdb tgquestionstotal tgquestionslist
    set tgquestionstotal 0
    set tgquestionslist ""
    set qfile [open $tgqdb r]
    set tgquestionslist [split [read -nonewline $qfile] "\n"]
    set tgquestionstotal [llength $tgquestionslist]
    close $qfile
}

#selectionne la prochaine question.
proc tgnextq {} {
    global tgqdb tgcurrentquestion tgcurrentanswer tgquestionnumber
    global tgquestionstotal tghintnum tgchan tgquestionslist tgqdbsep tgqdbquestionfirst
    global tgcapsquestion tgcapsanswer
    tgreadqdb
    set tgcurrentquestion ""
    set tgcurrentanswer ""
    while {$tgcurrentquestion == ""} {
        set tgquestionnumber [rand [llength $tgquestionslist]]            
        set tgquestionselected [lindex $tgquestionslist $tgquestionnumber]
        set tgcurrentquestion [lindex [split $tgquestionselected $tgqdbsep] [expr $tgqdbquestionfirst^1]]
        if {$tgcapsquestion==1} {
            set tgcurrentquestion [strupr $tgcurrentquestion]
        }
        set tgcurrentanswer [string trim [lindex [split $tgquestionselected $tgqdbsep] $tgqdbquestionfirst]]
        if {$tgcapsanswer==1} {
            set tgcurrentanswer [strupr $tgcurrentanswer]
        }
    }
    unset tghintnum
    tghint
    bind pubm -|- "$tgchan *" tgcheckanswer
    return
}

#Mise en place des indices.
proc tghint {} {
    global tgmaxhint tghintnum tgcurrentanswer tghinttimer tgchan
    global tgtimehint tghintchar tgquestionnumber tgquestionstotal
    global tgcurrentquestion tghintcharsused tgnextqtimer tgtimenext tgstreak tgstreakmin
    global tgnobodygotit tgtrythenextone tgmissed tgmaxmissed tgcmdstart tgshowanswer
    global tgtimestart tgtimeanswer tgalwaysshowq tgmaxhintcurrent tgtempnohint tgcapshint
    if {[catch {incr tghintnum}]!=0} {
        set tghintnum 0
        regsub -all -- "\[^A-Za-z0-9\]" [no_accent $tgcurrentanswer] "" _hintchars
        set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
        catch {tgunbindhintcmd}
        if {$tgmaxhintcurrent>0} {
            set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
        }
    }
    if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
        incr tgmissed
        set _msg ""
        append _msg "[tgcolmiss][lindex $tgnobodygotit [rand [llength $tgnobodygotit]]]"
        if {$tgshowanswer==1} {
            append _msg " La réponse est [tgcolmisc2]$tgcurrentanswer[tgcolmiss]."
        }
        if {$tgmaxmissed>0&&$tgmissed>=$tgmaxmissed} {
            append _msg " Cela fait $tgmissed questions sans réponse ! Le quizz est automatiquement arrêté. pour le relancer, taper $tgcmdstart"
            tgquietstop
        } else {
            append _msg " [lindex $tgtrythenextone [rand [llength $tgtrythenextone]]]"
        }
        tggamemsg "[tgcolmiss]$_msg"
        if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
        set tgstreak 0
        catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
        if {$tgmaxmissed==0||$tgmissed<$tgmaxmissed} {
            set tgnextqtimer [utimer $tgtimenext tgnextq]
        }
        return
    } elseif {$tghintnum == 0} {
        set i 0
        set _hint {}
        set tghintcharsused {}
        foreach word [split $tgcurrentanswer] {
            regsub -all -- "\[A-Za-z0-9\]" [no_accent $word] $tghintchar _current
            lappend _hint $_current
        }
        if {$tgtimeanswer==1} {
            set tgtimestart [clock clicks -milliseconds]
        }
    } elseif {$tghintnum == 1} {
        set i 0
        set _hint {}
        while {$i<[llength [split $tgcurrentanswer]]} {
            set _word [lindex [split $tgcurrentanswer] $i]
            set j 0
            set _newword {}
            while {$j<[strlen $_word]} {
                if {$j==0} {
                    append _newword [stridx $_word $j]
                    lappend tghintcharsused $i,$j
                } else {
                    if {[string is alnum [stridx $_word $j]]} {
                        append _newword $tghintchar
                    } else {
                        append _newword [stridx $_word $j]
                        lappend tghintcharsused $i,$j
                    }
                }
                incr j
            }
            lappend _hint $_newword
            incr i
        }
        } else {
            set i 0
            set _hint {}
            while {$i<[llength [split $tgcurrentanswer]]} {
                set _word [lindex [split $tgcurrentanswer] $i]
                set j 0
                set _newword {}
                set _selected [rand [strlen $_word]]
                regsub -all -- "\[^A-Za-z0-9\]" [no_accent $_word] "" _wordalnum
                if {[strlen $_wordalnum]>=$tghintnum} {
                    while {[lsearch $tghintcharsused $i,$_selected]!=-1||[string is alnum [stridx $_word $_selected]]==0} {
                     set _selected [rand [strlen $_word]]
                    }
                }
                lappend tghintcharsused $i,$_selected
                while {$j<[strlen $_word]} {
                    if {[lsearch $tghintcharsused $i,$j]!=-1||[string is alnum [stridx $_word $j]]==0} {
                        append _newword [stridx $_word $j]
                    } else {
                        if {[string is alnum [stridx $_word $j]]} {
                            append _newword $tghintchar
                        }
                }
                incr j
            }
            lappend _hint $_newword
            incr i
        }
    }
    if {$tgcapshint==1} {
        set _hint [strupr $_hint]
    }
    tggamemsg "[tgcolqhead]===== Question [expr $tgquestionnumber+1]/$tgquestionstotal [expr $tghintnum?"(Indice $tghintnum/$tgmaxhintcurrent)":""] ====="
    if {$tgalwaysshowq==1||$tghintnum==0} {
        tggamemsg "[tgcolqbody]$tgcurrentquestion"
    }
    tggamemsg "[tgcolhint]Aide: [join $_hint]"
    set tghinttimer [utimer $tgtimehint tghint]
}

#déclenché quand quelqu'un emploie la commande !top10
proc tgshowtop10 {nick host hand chan text} {
    global tgscores tgchan tgscorestotal
    if {[strlwr $chan]==[strlwr $tgchan]} {
        tggetscores
        if {$tgscorestotal>0} {
            if {$tgscorestotal>9} {
                set _max 9
            } else {
                set _max [expr $tgscorestotal-1]
            }
            set i 0
            while {$i<=$_max} {
                set _item [lindex $tgscores $i]
                set _nick [join [lindex [split $_item ,] 2]]
                set _score [join [lindex [split $_item ,] 0]]
                if {$i==0} {
                    append _scores "[tgcolscr1]$_nick $_score"
                } elseif {$i==1} {
                    append _scores ", [tgcolscr2]$_nick $_score"
                } elseif {$i==2} {
                    append _scores ", [tgcolscr3]$_nick $_score"
                } else {
                    append _scores ", [tgcolmisc1]$_nick $_score"
                }
                incr i
            }
            tggamemsg "[tgcolmisc1]Top 10: $_scores"
        } else {
            tggamemsg "[tgcolmisc1]Pas de score pour l'instant."
        }
    }
}

#vérifie si n'importe qui a indiqué la réponse correcte sur le canal.
proc tgcheckanswer {nick host hand chan text} {
    global tgcurrentanswer
    putlog [tgstripcodes $text]
    if {[strlwr [no_accent $tgcurrentanswer]] == [tgstripcodes [strlwr [string trim [no_accent $text]]]]} {
        tgcorrectanswer $nick
    }
}

#déclenché quand quelqu'un dit la réponse correcte.
proc tgcorrectanswer {nick} {
    global tgcurrentanswer tghinttimer tgtimenext tgchan tgnextqtimer tgstreak tgstreakmin
    global tgscoresbyname tgranksbyname tgranksbynum tgcongrats tgscorestotal tgmissed
    global tgtimestart tgshowallscores tgrealnames tgscoresbyrank tgtimeanswer tgmulti
    tggetscores
    if {![info exists tgranksbyname([strlwr $nick])]} {
        set _oldrank 0
    } else {
        set _oldrank $tgranksbyname([strlwr $nick])
    }
    tgincrscore $nick
    tggetscores
    set _newrank $tgranksbyname([strlwr $nick])
    set _timetoanswer ""
    if {$tgtimeanswer==1} {
        set _timetoanswer [expr [expr [clock clicks -milliseconds]-$tgtimestart]/1000.00]
    }
    set _msg "[tgcolmisc1][lindex $tgcongrats [rand [llength $tgcongrats]]] [tgcolmisc2]$nick[tgcolmisc1]! La réponse était [tgcolmisc2]$tgcurrentanswer[tgcolmisc1].[expr $tgtimeanswer==1?" Tu l'as trouvé en [tgcolmisc2]$_timetoanswer[tgcolmisc1] seconds.":""]"
    if {$_newrank<$_oldrank} {
        if {$_newrank==1} {
            append _msg " Tu es maintenant en 1er position!"
        } else {
            if {$tgshowallscores==0} {
                append _msg " Tu as changé de place!"
            } else {
                append _msg " Tu est maintenant classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])][tgcolmisc1] sur [tgcolmisc2]$tgscorestotal[tgcolmisc1], derrière [tgcolmisc2]$tgrealnames($tgranksbynum([expr $_newrank-1]))[tgcolmisc1] avec [tgcolmisc2]$tgscoresbyrank([expr $_newrank-1])[tgcolmisc1]."
            }
        }
    }
    tggamemsg "$_msg"
    if {$tgstreak!=0} {
        if {[lindex [split $tgstreak ,] 0]==[strlwr $nick]} {
            set tgstreak [strlwr $nick],[expr [lindex [split $tgstreak ,] 1]+1]
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} {
                tggamemsg "[tgcolstrk][tgcolmisc2]$nick[tgcolstrk] [lindex $tgmulti [rand [llength $tgmulti]]] [tgcolmisc2][lindex [split $tgstreak ,] 1] [tgcolstrk]réponses consécutives!"
            }
        } else {
            if {$tgstreakmin>0&&[lindex [split $tgstreak ,] 1]>=$tgstreakmin} { tgstreakend }
            set tgstreak [strlwr $nick],1
        }
    } else {
        set tgstreak [strlwr $nick],1
    }
    set tgmissed 0
    tgshowscores $nick
    catch {unbind pubm -|- "$tgchan *" tgcheckanswer}
    killutimer $tghinttimer
    set tgnextqtimer [utimer $tgtimenext tgnextq]
}

#lire les scores à partir du fichier, les classés  et les entreposé dans la variable.
proc tggetscores {} {
    global tgscf tgscorestotal tgscores tgscoresbyname tgranksbyname tgranksbynum
    global tgrealnames tgscoresbyrank
    if {[file exists $tgscf]&&[file size $tgscf]>2} {
        set _sfile [open $tgscf r]
        set tgscores [lsort -dict -decreasing [split [gets $_sfile]]]
        close $_sfile
        set tgscorestotal [llength $tgscores]
    } else {
        set tgscores ""
        set tgscorestotal 0
    }
    if {[info exists tgscoresbyname]} {unset tgscoresbyname}
    if {[info exists tgranksbyname]} {unset tgranksbyname}
    if {[info exists tgrealnames]} {unset tgrealnames}
    if {[info exists tgranksbynum]} {unset tgranksbynum}
    set i 0
    while {$i<[llength $tgscores]} {
        set _item [lindex $tgscores $i]
        set _nick [lindex [split $_item ,] 2]
        set _lwrnick [lindex [split $_item ,] 3]
        set _score [lindex [split $_item ,] 0]
        set tgscoresbyname($_lwrnick) $_score
        set tgrealnames($_lwrnick) $_nick
        set tgranksbyname($_lwrnick) [expr $i+1]
        set tgranksbynum([expr $i+1]) $_lwrnick
        set tgscoresbyrank([expr $i+1]) $_score
        incr i
    }
    return
}

#incrément les points de la personne points.
proc tgincrscore {who} {
    global tgscores tgscf tgpointsperanswer tgscorestotal tgscoresbyname tghintnum
    tggetscores
    if {$tgscorestotal>0} {
        set i 0
        if {![info exists tgscoresbyname([strlwr $who])]} {
	        append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
            #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who] "
        }
        while {$i<[llength $tgscores]} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _time [lindex [split $_item ,] 1]
            set _score [lindex [split $_item ,] 0]
            if {[strlwr $who]==[strlwr $_nick]} {
	            append _newscores "[expr $_score+$tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
                #append _newscores "[expr $_score+$tgpointsperanswer],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            } else {
                append _newscores "$_score,$_time,$_nick,[strlwr $_nick][expr [expr [llength $tgscores]-$i]==1?"":"\ "]"
            }
            incr i
        }
    } else {
	    append _newscores "[expr $tgpointsperanswer-$tghintnum],[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
        #append _newscores "1,[expr 1000000000000.0/[unixtime]],$who,[strlwr $who]"
    }
    set _sfile [open $tgscf w]
    puts $_sfile "$_newscores"
    close $_sfile
    return
}

#montre les points courants sur le canal.
proc tgshowscores {nick} {
    global tgscores tgchan tgscorestotal tgshowallscores tgranksbyname tgranksbynum
    global tgscoresbyname tgrealnames tgscoresbyrank
    tggetscores
    set i 0
    if {$tgshowallscores} {
        while {$i<[llength $tgscores]} {
            set _item [lindex $tgscores $i]
            set _nick [lindex [split $_item ,] 2]
            set _score [lindex [split $_item ,] 0]
            if {$i==0} {
                append _scores "[tgcolscr1]$_nick $_score"
            } elseif {$i==1} {
                append _scores ", [tgcolscr2]$_nick $_score"
            } elseif {$i==2} {
                append _scores ", [tgcolscr3]$_nick $_score"
            } elseif {[onchan $_nick $tgchan]} {
                append _scores ", [tgcolmisc1]$_nick $_score"
            }
            incr i
        }
        tggamemsg "[tgcolmisc1]Les scores: $_scores"
    } else {
        if {$tgranksbyname([strlwr $nick])==1} {
            set _tgt "."
        } else {
            set _tgt ", derrière [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1] avec [tgcolmisc2]$tgscoresbyrank([expr $tgranksbyname([strlwr $nick])-1])[tgcolmisc1]."
        }
        tggamemsg "[tgcolmisc2]$nick [tgcolmisc1]a maintenant [tgcolmisc2]$tgscoresbyname([strlwr $nick]) [tgcolmisc1][expr $tgscoresbyname([strlwr $nick])==1?"point":"points"] et est classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $nick])] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]$_tgt"
    }
}

#remettre à zéro les scores.
proc tgresetscores {nick host hand text} {
    global tgscf tgscorestotal tgscores tgplaying tgresetreqpw
    if {($tgresetreqpw==1 && [passwdok $hand $text]) || $tgresetreqpw==0} {
        if {[file exists $tgscf]&&[file size $tgscf]>2} {
            set _sfile [open $tgscf w]
            puts $_sfile ""
            close $_sfile
            set tgscores ""
            set tgscorestotal 0
        }
        tggamemsg "[tgcolrset]===== Mise à zéro du classement par $nick! ====="
    }
}

#déclenché quand une série dis de 'bonne réponse' est fini.
proc tgstreakend {} {
        global tgstreak tgrealnames
        tggamemsg "[tgcolstend]Dommage pour [tgcolmisc2]$tgrealnames([lindex [split $tgstreak ,] 0])[tgcolstend] qui avait l'air en forme !"
        return
}

#déclenché quand quelqu'un join le chan.
proc tgjoinmsg {nick host hand chan} {
    global botnick tgplaying tgcmdhelp tgcmdstart tgflagsstart tgcmdstop tgflagsstop tgchan
    if {$nick != $botnick} {
        set _msg ""
        append _msg "Le quizz est actuellement"
        if {$tgplaying==1} {
            append _msg " \002activé\002."
        } else {
            append _msg " \002désactivé\002."
        }
        if {[matchattr $hand $tgflagsstart $tgchan]&&$tgplaying==0} {
            append _msg " Pour démarrer le jeu , taper \002$tgcmdstart\002 sur $tgchan."
        }
        if {[matchattr $hand $tgflagsstop $tgchan]&&$tgplaying==1} {
            append _msg " Pour stopper le jeu , taper \002$tgcmdstop\002 sur $tgchan."
        }
        append _msg " Taper \002/MSG $botnick [strupr $tgcmdhelp]\002 Pour voir l'aide. Bon jeu à toi ! :-)"
        puthelp "[tgpriv] $nick :$_msg"
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de consultation de points.
proc tgscorelookup {nick host hand text} {
    global tgscoresbyname tgranksbyname tgscorestotal tgrealnames
    if {$text==""} { set text $nick } else { set text [lindex [split $text] 0] }
    tggetscores
    if {![info exists tgscoresbyname([strlwr $text])]} {
        if {[strlwr $text]==[strlwr $nick]} {
            set _who "[tgcolmisc1]Tu as"
        } else {
            set _who "[tgcolmisc2]$text [tgcolmisc1]est"
        }
        puthelp "[tgpriv] $nick :[tgbold]$_who [tgcolmisc1]visiblement pas classé."
    } else {
        if {[strlwr $text]==[strlwr $nick]} {
            set _who "[tgcolmisc1]Tu as"
        } else {
            set _who "[tgcolmisc2]$tgrealnames([strlwr $text]) [tgcolmisc1]a"
        }
        puthelp "[tgpriv] $nick :[tgbold]$_who [tgcolmisc2]$tgscoresbyname([strlwr $text])[tgcolmisc1] points, classé [tgcolmisc2][ordnumber $tgranksbyname([strlwr $text])] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de consultation de cible.
proc tgtargetlookup {nick host hand text} {
    global tgscoresbyname tgranksbyname tgscorestotal tgranksbynum tgrealnames
    tggetscores
    if {![info exists tgscoresbyname([strlwr $nick])]} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu n'es pas dans le classement."
    } elseif {$tgranksbyname([strlwr $nick])==1} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu es à la [tgcolmisc2]1ère[tgcolmisc1] place!"
    } else {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu as [tgcolmisc2]$tgscoresbyname([strlwr $nick])[tgcolmisc1] points. Devant toi se trouve [tgcolmisc2]$tgrealnames($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1])) [tgcolmisc1]avec [tgcolmisc2]$tgscoresbyname($tgranksbynum([expr $tgranksbyname([strlwr $nick])-1]))[tgcolmisc1] points, placé [tgcolmisc2][ordnumber [expr $tgranksbyname([strlwr $nick])-1]] [tgcolmisc1]sur [tgcolmisc2]$tgscorestotal[tgcolmisc1]."
    }
 
}

#déclenché quand quelqu'un /msgs le BOT avec la commande de reportage d'erreur.
proc tgerror {nick host hand text} {
    global tgquestionstotal tgquestionslist tgerrmethod tgerrfil tgerremail tgerrmailtmp
    if {$text==""||![string is int [lindex [split $text] 0]]} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Tu dois spécifier un numéro de question."
        return
    }
    tgreadqdb
    set _qnum [lindex [split $text] 0]
    if {$_qnum>$tgquestionstotal} {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Cette question n'existe pas."
        return
    }
    set _qques [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 1]
    set _qans [lindex [split [lindex $tgquestionslist [expr $_qnum-1]] |] 0]
    set _desc [join [lrange [split $text] 1 end]]
    if {$_desc==""} { set _desc "Aucune autre information donnée pour cette erreur." }
    if {$tgerrmethod==1} {
        set _fname $tgerrmailtmp/trivia[rand 100000].tmp
        set _file [open $_fname w]
    } else {
        set _file [open $tgerrfil a]
    }
    puts $_file ""
    puts $_file "Rapport d'erreur généré le [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S]"
    puts $_file "Reporter par:\t$nick!$host"
    puts $_file "Question n°:\t$_qnum"
    puts $_file "Question:\t\t$_qans"
    puts $_file "Réponse:\t\t$_qques"
    puts $_file "Commentaire:\t$_desc"
    puts $_file "------------------------------"
    close $_file
    if {$tgerrmethod==1} {
        exec mail -s "trivia.tcl erreur reportée par $nick" $tgerremail < $_fname
        file delete $_fname
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Merci! Votre report d'erreur a été envoyé par e-mail à l'owner."
    } else {
        puthelp "[tgpriv] $nick :[tgbold][tgcolmisc1]Merci! Votre report d'erreur a été enregistré, il sera regardé dès que possible."
    }
 
}

#déclenché quand quelqu'un /msg le BOT avec la commande pour voir les règles.
proc tgrulesmsg {nick host hand text} {
    global tgrules
    puthelp "[tgpriv] $nick :Voici les règles à respecter: $tgrules"
}

#déclenché quand quelqu'un /msg le BOT avec la commande d'aide.
proc tggivehelp {nick host hand {text ""}} {
    global botnick tgcmdlookup tgcmdhelp tgcmdstart tgcmdstop tgchan tgflagsstop
    global tgcmdstop tgflagshint tgcmdhint tgflagsskip tgcmdskip tgflagsreset tgcmdreset
    global tgcmdtarget tgcmderror tgcmdrules tgflagsstart
    if {$text==""} {
        puthelp "[tgpriv] $nick :Vous avez acceè aux /MSG commands:"
        puthelp "[tgpriv] $nick :taper, /MSG $botnick <command>"
        puthelp "[tgpriv] $nick :  \002[strupr $tgcmdrules]\002"
        puthelp "[tgpriv] $nick :   -- Listes des règles du canal."
        puthelp "[tgpriv] $nick :  \002[strupr $tgcmdlookup]\002 \[nick\]"
        puthelp "[tgpriv] $nick :   -- Voir le rang et les points de \[nick\], si spécifié,"
        puthelp "[tgpriv] $nick :    autrement, voir votre propres rang et points."
        puthelp "[tgpriv] $nick :  \002[strupr $tgcmdtarget]\002"
        puthelp "[tgpriv] $nick :   -- Voir votre rang et le rang et les points de la personne "
        puthelp "[tgpriv] $nick :    qui est devant vous."
        puthelp "[tgpriv] $nick :  \002[strupr $tgcmderror]\002 <numéro> \[description\]"
        puthelp "[tgpriv] $nick :   -- Rapporter les erreurs sur la question <numéro>"
        puthelp "[tgpriv] $nick :    La description doit être complète et claire afin de résoudre ce problème rapidement et facilement."
        if {[matchattr $hand $tgflagsreset $tgchan]} {
            puthelp "[tgpriv] $nick :  \002[strupr $tgcmdreset]\002"
            puthelp "[tgpriv] $nick :   -- Remet le classement a zéro."
        }
        puthelp "[tgpriv] $nick :Pour avoir la liste des commandes chan, /MSG $botnick [strupr $tgcmdhelp] PUBCMDS"
    }
        if {[strlwr $text]=="pubcmds"} {
        puthelp "[tgpriv] $nick :Vous avez accès aux commandes suivantes:"
        if {[matchattr $hand $tgflagsstart $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdstart\002 -- Démarrer le Quizz."
        }
        if {[matchattr $hand $tgflagsstop $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdstop\002 -- Stopper le Quizz."
        }
        if {[matchattr $hand $tgflagshint $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdhint\002 -- Donner un indice."
        }
        if {[matchattr $hand $tgflagsskip $tgchan]} {
            puthelp "[tgpriv] $nick :  \002$tgcmdskip\002 -- Passer à la question suivantes."
        }
        puthelp "[tgpriv] $nick :Pour avoir la liste des /MSG commands, /MSG $botnick [strupr $tgcmdhelp]"
 
    }
}
# Renvoie le texte sans codes de couleur, "bold", etc. de commande.
# C'est dépouillé en bas de la version du proc dans MC_8's mc.moretools.tcl.
proc tgstripcodes {text} {
    regsub -all -- "\003(\[0-9\]\[0-9\]?(,\[0-9\]\[0-9\]?)?)?" $text "" text
    set text "[string map -nocase [list \002 "" \017 "" \026 "" \037 ""] $text]"
    return $text
}
 
proc tggamemsg {what} {
    global tgchan
    putquick "PRIVMSG $tgchan :[tgbold]$what"
}
 
proc tgbold {} {
    global tgusebold
    if {$tgusebold==1} { return "\002" }
}
proc tgcolstart {} {
    global tgcolourstart
    if {$tgcolourstart!=""} { return "\003$tgcolourstart" }
}
proc tgcolstop {} {
    global tgcolourstop
    if {$tgcolourstop!=""} { return "\003$tgcolourstop" }
}
proc tgcolskip {} {
    global tgcolourskip
    if {$tgcolourskip!=""} { return "\003$tgcolourskip" }
}
proc tgcolerr {} {
    global tgcolourerr
    if {$tgcolourerr!=""} { return "\003$tgcolourerr" }
}
proc tgcolmiss {} {
    global tgcolourmiss
    if {$tgcolourmiss!=""} { return "\003$tgcolourmiss" }
}
proc tgcolqhead {} {
    global tgcolourqhead
    if {$tgcolourqhead!=""} { return "\003$tgcolourqhead" }
}
proc tgcolqbody {} {
    global tgcolourqbody
    if {$tgcolourqbody!=""} { return "\003$tgcolourqbody" }
}
proc tgcolhint {} {
    global tgcolourhint
    if {$tgcolourhint!=""} { return "\003$tgcolourhint" }
}
proc tgcolstrk {} {
    global tgcolourstrk
    if {$tgcolourstrk!=""} { return "\003$tgcolourstrk" }
}
proc tgcolscr1 {} {
    global tgcolourscr1
    if {$tgcolourscr1!=""} { return "\003$tgcolourscr1" }
}
proc tgcolscr2 {} {
    global tgcolourscr2
    if {$tgcolourscr2!=""} { return "\003$tgcolourscr2" }
}
proc tgcolscr3 {} {
    global tgcolourscr3
    if {$tgcolourscr3!=""} { return "\003$tgcolourscr3" }
}
proc tgcolrset {} {
    global tgcolourrset
    if {$tgcolourrset!=""} { return "\003$tgcolourrset" }
}
proc tgcolstend {} {
    global tgcolourstend
    if {$tgcolourstend!=""} { return "\003$tgcolourstend" }
}
proc tgcolmisc1 {} {
    global tgcolourmisc1
    if {$tgcolourmisc1!=""} { return "\003$tgcolourmisc1" }
}
proc tgcolmisc2 {} {
    global tgcolourmisc2
    if {$tgcolourmisc2!=""} { return "\003$tgcolourmisc2" }
}
proc tgpriv {} {
    global tgpriv2msg
    if {$tgpriv2msg==1} { return "PRIVMSG" } else { return "NOTICE" }
}

#ceci produit une page HTML avec toutes les personnes sur le chan avec
#leurs points, aussi bien qu'une liste de tous les points, assortie par le rang
proc tghtml {} {
    global tgchan botnick tghtmlfile tghtmlrefresh server tgscoresbyname tgranksbyname
    global tgscorestotal tgranksbyname tgrealnames tgscoresbyrank tgranksbynum tgplaying
    global tgquestionstotal tghtmlrefreshtimer tghtmlfont
    tggetscores
    tgreadqdb
    set _file [open $tghtmlfile~new w]
    puts $_file "<!DOCTYPE HTML PUBLIC \"-/W3C/DTD HTML 4.01 Transitional/EN\">"
    puts $_file "<html>"
    puts $_file " <head>"
    puts $_file "  <title>Quizz sur $tgchan </title>"
    puts $_file "  <meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">"
    puts $_file "  <meta http-equiv=\"refresh\" content=\"$tghtmlrefresh\">"
    puts $_file "  <meta name=\"generator\" content=\"trivia.tcl script pour eggdrop. http://www.eggdrop.za.net/\">"
    puts $_file "  <style type=\"text/css\">"
    puts $_file "  <!--"
    puts $_file "  body,td{font-family:$tghtmlfont;font-size:13px;}"
    puts $_file "  a{text-decoration:none;color:#09f;}"
    puts $_file "  -->"
    puts $_file "  </style>"
    puts $_file " </head>"
    puts $_file " <body>"
    puts $_file "  <h1>$tgchan sur [lindex [split $server :] 0]</h1>"
    puts $_file "  <hr size=\"1\" noshade>"
    if {![onchan $botnick $tgchan]} {
        puts $_file "  <p>Hmmm... Il y a personne de connecté sur le chan pour le moment.</p>"
    } else {
        puts $_file "  <p>Le quizz est actuellement  <b>[expr $tgplaying==1?"activé":"désactivé"]</b>. Il y a <b>$tgquestionstotal</b> questions dans la database."
        puts $_file "  <p>En ce moment sur $tgchan :<br>"
        puts $_file "  <table width=\"50%\" border=\"1\" cellspacing=\"0\" cellpadding=\"0\"><tr><td><table width=\"100%\" cellspacing=\"3\" border=\"0\">"
        puts $_file "   <tr>"
        puts $_file "    <td><b>Nick</b></td>"
        puts $_file "    <td><b>Score</b></td>"
        puts $_file "    <td><b>place</b></td>"
        puts $_file "    <td><b>Idle</b></td>"
        puts $_file "   </tr>"
        foreach nick [lsort [chanlist $tgchan]] {
            puts $_file "   <tr>"
            puts $_file "    <td>[expr [isop $nick $tgchan]?"@":""][expr [isvoice $nick $tgchan]?"+":""]$nick[expr [string match $nick $botnick]?" (C moi!)":""]</td>"
            if {[info exists tgscoresbyname([strlwr $nick])]} {
                puts $_file "    <td>$tgscoresbyname([strlwr $nick])</td>"
            } else {
                puts $_file "    <td>-</td>"
            }
            if {[info exists tgranksbyname([strlwr $nick])]} {
                puts $_file "    <td>$tgranksbyname([strlwr $nick])</td>"
            } else {
                puts $_file "    <td>-</td>"
            }
            puts $_file "   <td>[expr [getchanidle $nick $tgchan]>10?"[getchanidle $nick $tgchan]m":"-"]</td>"
            puts $_file "   </tr>"
        }
        puts $_file "  </table></td></tr></table>"
    }
    if {$tgscorestotal>0} {
        puts $_file "  <p><small>il y a <b>$tgscorestotal</b> [expr $tgscorestotal==1?"nick":"nicks"] dans le classement:<br>"
        set _rank 1
        while {$_rank<=$tgscorestotal} {
            puts $_file "  <b>$_rank</b>. $tgrealnames($tgranksbynum($_rank)) $tgscoresbyrank($_rank)<br>"
            incr _rank
        }
    } else {
        puts $_file "  <p><small>Il n'y a actuellement personne dans le classement.<br>"
    }
    puts $_file "  </small></p>"
    puts $_file "  <hr size=\"1\" noshade>"
    puts $_file "  <small>Générée le [strftime %A,\ %d\ %B\ %Y\ @\ %H:%M:%S] avec <a href=\"http://www.eggdrop.za.net/\">trivia.tcl</a> pour <a href=\"http://www.eggheads.org\">eggdrop</a>.<br>"
    puts $_file "  Cette page est réactualisée automatiquement toutes les [expr $tghtmlrefresh==1?"second":"$tghtmlrefresh seconds"].</small>"
    puts $_file " </body>"
    puts $_file "</html>"
    close $_file
    file rename -force $tghtmlfile~new $tghtmlfile
    set tghtmlrefreshtimer [utimer $tghtmlrefresh tghtml]
}
 
putlog "======================================================="
putlog "* trivia.tcl $tgver ($tgrel) by Souperman loaded."
putlog "* Visit http://www.eggdrop.za.net/ for updates."
tgreadqdb
putlog "* $tgquestionstotal questions dans $tgqdb ([file size $tgqdb] bytes)"
putlog "======================================================="


Répondre Avertir
#3
A priori, il manque une initialisation de cette variable au lancement du jeu.
J'imagine que ça devrait être fait dans:
TCL
proc tgnextq {} {


Après le
TCL
set tgcurrentanswer ""


, j'ajouterais:
TCL
set ::tgmaxhintcurrent $::tgmaxhint


Répondre
#4
Bonjour à vous tout d'abord merci pour ce site kiff bien pour les bot. Smile Voilà sa fait la même erreur que EricPompier s'essaie de regarder la panne comme CrazyCat explique mais je voir pas ou faut changer -_-" si quelqu'un pourrai regarder sa serai cool merci à vous =)
Répondre Avertir
#5
c'est pourtant pas compliqué, tu cherches la ligne qui débute avec (si tu as une mauvaise vue, utilises la fonction recherche de ton logiciel):
TCL
proc tgnextq {} {



Par contre j'aurai vider la variable moi (valeur 0 ou vide), au lieu de lui donner la valeur de $tgmaxhint.
CrazyCat a écrit :La prochaine fois, essaye d'imaginer que j'ai un cerveau ...
Répondre Avertir
#6
Visiblement, le problème est le même que celui que MenzAgitat avait rencontré sur le script JService au passage à eggdrop 1.6.19 (d'ailleurs les deux codes sont carrément semblables en certains points ><).
Le problème viendrait de cette partie:
TCL
if {[catch {incr tghintnum}]!=0} {
        set tghintnum 0
        regsub -all -- "\[^A-Za-z0-9\]" [no_accent $tgcurrentanswer] "" _hintchars
        set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
        catch {tgunbindhintcmd}
        if {$tgmaxhintcurrent>0} {
            set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
        }
    }
    if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
        incr tgmissed



Et surtout plus particulièrement de cette ligne:
TCL
if {[catch {incr tghintnum}]!=0} {


Le but de cette ligne est de vérifier si la variable tghintnum existe, et de l'incrémenter.
Si elle n'existe pas, elle est initialisée à 0, et on entre dans la boucle.
C'est quand même un peu bidon, et ça provoque des erreur dans le catch

Pour comprendre d'ou viens le problème, il faut regarder de plus prêt la commande incr.
Vous comprendrez mieux en voyant ceci :
Boulet #1 a écrit :firartix@Manchot:~$ tclsh8.4
% incr stupidVar 1
can't read "stupidVar": no such variable
Boulet #2 a écrit :firartix@Manchot:~$ tclsh8.5
% incr stupidVar 1
1

En effet, depuis la version 8.5 de TCL, la commande incr ne provoque plus d'erreur si elle n'est pas initialisée : elle l'initialise à 0 et continue normalement
Du coup, l'erreur (variable inexistante) n'est pas detectée, et on entre pas dans la boucle. Et au final, la variable tgmaxhintcurrent n'existe pas, et le script se casse les dents sur la vérification d'après !
En réalité, c'est très simple à corriger. La variable étant mise à 0 si elle n'existe pas (donc l'incr n'a pas d'effet), il suffit de vérifier si elle existe
J'ai déjà testé ce code sur JService, et il fonctionne :

TCL
if {![info exists tghintnum]} {
        set tghintnum 0
        regsub -all -- "\[^A-Za-z0-9\]" [no_accent $tgcurrentanswer] "" _hintchars
        set tgmaxhintcurrent [expr [strlen $_hintchars]<=$tgmaxhint?[expr [strlen $_hintchars]-1]:$tgmaxhint]
        catch {tgunbindhintcmd}
        if {$tgmaxhintcurrent>0} {
            set tgrebindhinttimer [utimer $tgtempnohint tgbindhintcmd]
        }
    } else { incr tghintnum }
    if {$tghintnum >= [expr $tgmaxhintcurrent+1]} {
        incr tgmissed



Les seuls changement étant le remplacement du catch par un info exists (pour vérifier l'existance de la variable) et l'ajout du else à la fin du bloc if (pour incrémenter la variable si elle existait)
Répondre Avertir
#7
Ni quel grand grand merci Artix tes explication sont super =) merci :p
Répondre Avertir
#8
bonjour voila j'ai fait les modification donner par crazy mais le quiiz ne prend pas en compte se que je dis ... vous auriez une solution ???
Répondre Avertir
#9
bonjour kan on donne la bonne reponce voici le msg en pl et la commande !prochaine marche pas

Tcl error [tgcheckanswer]: can't read "tgtimestart": no such variable
Répondre Avertir


Atteindre :


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