Communauté Eggdrop
[Demande] bind pubm SQL - Version imprimable

+- Communauté Eggdrop (https://forum.eggdrop.fr)
+-- Forum : Eggdrop et TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=8)
+--- Forum : Scripts TCL (https://forum.eggdrop.fr/forumdisplay.php?fid=4)
+--- Sujet : [Demande] bind pubm SQL (/showthread.php?tid=1682)

Pages : 1 2


RE: bind pubm SQL - DiXiT - 01/04/2017

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


RE: bind pubm SQL - CrazyCat - 02/04/2017

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
}





RE: bind pubm SQL - DiXiT - 02/04/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 !