cestlemien a écrit :je voulait juste demontrer/chercher que si le +c est appliqué sur un des salons ou le bombe.tcl est actif, la plupart des message ne pourront être delivrés sur le dit salon à cause des couleurs dans le script.Et donc chercher une solution, soit la detection du +c, soit et faire agir le bot en fonction.Je ne vois en rien là dedans le fait que l'on "invente" quelque chose.
La détection du +c était présente dans la première version qu'a donné alias_angelius, le souci était qu'il mettait les mêmes messages (avec les codes couleurs donc) dans les deux cas (présence ou non du +c).
Tout ce qu'il avait à faire était de supprimer les codes couleurs dans 50% des putserv.
La correction qu'alias_angelius a faite est encore pire que tout, on dirait que des lignes ont été effacées au hasard.
J'ai fait un petite version (non testée) qui vous fera peut-être comprendre comment on réfléchit à un développement:
tcl
# bombe.tcl
# !bomb <pseudo>
# !cut <couleur>
bind pub - !bomb bombe:pub
bind pub - !cut cut:pub
set fils(couleur) {
jaune
rouge
marron
bleu
vert
noir
violet
orange
gris
cyan
blanc
fushia
}
set bombe(set) 0
set bombe(nick) ""
set bombe(kickeur) ""
set bombe(good) ""
set bombe(list) ""
set bombe(timer) ""
set bombe(chan) ""
set bombe(antifloodt) ""
set bombe(antiflood) 0
set bombe(antiflood2) 0
proc antiflood:bomb {chan} {
global bombe
if {$bombe(antiflood) >= 3} {
if {$bombe(antiflood2) == 1} { return 0 }
putserv "PRIVMSG $chan :Contrôle de flood activé pour la commande !bomb : pas plus de 3 requête(s) toutes les 200 secondes."
set bombe(antiflood2) 1
set bombe(antifloodt) [utimer 200 {set bombe(antiflood) 0 ; set bombe(antiflood2) 0}]
return 0
} else {
incr bombe(antiflood)
}
}
proc filtout {chan text} {
if [string match "*c*" [getchanmode $chan]] {
return [stripcodes abcgru $text]
} else {
return $text
}
}
proc bombe:pub {nick uhost hand chan arg} {
global fils bombe botnick
if {[string tolower [lindex $arg 0]] == [string tolower $botnick]} {
putkick $chan $nick [filtout $chan "\00313O\0031wned \00313<3"]
return 0
}
if {$bombe(set) == 1} {
set msg [filtout $chan "\00314Bombe \| \0034Le jeu est deja en cours d'utilisation."]
putserv "PRIVMSG $chan :$msg"
return 0
}
if {[lindex $arg 0] == ""} {
set msg [filtout $chan "\00314Bombe\003 \| !bomb PSEUDO"]
putserv "PRIVMSG $chan :$msg"
return 0
}
if {![antiflood:bomb $chan]} { return 0 }
set bombe(set) 1
set bombe(nick) [lindex $arg 0]
set bombe(kickeur) $nick
set cdf [rand 4]
incr cdf
set x 0
set bombe(chan) $chan
set bombe(timer) [utimer 30 {putkick $bombe(chan) $bombe(nick) [filtout $bombe(chan) "\002Boum !!!\002 Temps écoulé !"]; set bombe(set) 0}]
while {$x<=$cdf} {
if {$x == 0} { set bombe(list) "" }
set bombe(list) "$bombe(list) [lindex $fils(couleur) [rand [llength $fils(couleur)]]]"
incr x
}
set bombe(good) [lindex $bombe(list) [rand [llength $bombe(list)]]]
putlog "$bombe(list) + $bombe(good)"
set msg [filtout $chan "\00314Bombe \| \0031Attention\0034 $bombe(nick) \0031Tu dois couper le bon fil tu as 30 secondes :\0034 $bombe(list) \0031( !cut couleur )"]
putserv "PRIVMSG $chan :$msg"
}
proc cut:pub {nick uhost hand chan arg} {
global bombe
if {$bombe(set) == 1} {
if {$nick == $bombe(nick)} {
if {[lindex $arg 0] == $bombe(good)} {
set msg [filtout $chan "\00314Bombe \| \0031Joli\0034 $nick !! Tu as trouvé le bon fil \0031:D"]
putserv "PRIVMSG $chan :$msg"
} else {
set msg
putkick $chan $nick [filtout $chan "\00314Boum !! Dtc !! Le bon fil était\0034 $bombe(good)"]
}
set bombe(set) 0
killutimer $bombe(timer)
} else {
set msg [filtout $chan "\00314Bombe\003 \| C'est a $bombe(nick) de couper le fil !"]
putserv "PRIVMSG $chan :$msg"
}
}
}
putlog "\[bomb\] a été chargé."
Editetite modification pour utiliser des putkick plutôt que des putserv "kick" partout.