Messages : 9
Sujets : 0
Inscription : Mar 2017
01/04/2017, 23:52
(Modification du message : 01/04/2017, 23:52 par DiXiT.)
Pour ma part, je ne sais pas comment set une liste a partir d'une base SQL aurais-tu un TCL ou un exemple sous la main s'il te plait @CrazyCat ? Merci
Messages : 2,381
Sujets : 208
Inscription : Apr 2004
02/04/2017, 00:14
(Modification du message : 02/04/2017, 00:23 par CrazyCat.)
Vous avez pourtant tous les éléments...
Dans la procédure d'initialisation du script:
tcl
mysqlsel $::mysqlink "SELECT mot, salon FROM box"
::mysql::map $::mysqlink { mot salon } {
lappend ::badwords([string tolower $salon]) $mot
}
Et le script "actif":
tcl
bind pubm - * verifmot
proc verifmot {nick uhost handle chan text} {
set chan [string tolower $chan]
set words [split [string tolower $text]]
set matches [lintersect $words $::badwords($chan)]
if {[llength $matches]>0 } {
putserv "PRIVMSG $chan :Badword(s) detected: [join $matches]"
}
return 0
}
proc lintersect {list1 list2} {
foreach element $list1 {
if { ($element in $list2) } { lappend intersect $element }
}
return $intersect
}
Messages : 9
Sujets : 0
Inscription : Mar 2017
(02/04/2017, 00:14)CrazyCat a écrit : Vous avez pourtant tous les éléments...
Dans la procédure d'initialisation du script:
tcl
mysqlsel $::mysqlink "SELECT mot, salon FROM box"
::mysql::map $::mysqlink { mot salon } {
lappend ::badwords([string tolower $salon]) $mot
}
Et le script "actif":
tcl
bind pubm - * verifmot
proc verifmot {nick uhost handle chan text} {
set chan [string tolower $chan]
set words [split [string tolower $text]]
set matches [lintersect $words $::badwords($chan)]
if {[llength $matches]>0 } {
putserv "PRIVMSG $chan :Badword(s) detected: [join $matches]"
}
return 0
}
proc lintersect {list1 list2} {
foreach element $list1 {
if { ($element in $list2) } { lappend intersect $element }
}
return $intersect
}
Super, merci beaucoup !