04/06/2013, 21:00
Bonjour,
Alors j'ai quelque peu réécris mon script en essayant d'utiliser une "fonction" global, ce qui donne :
Mais voila il y a un mais quand je le lance, dans la party line j'ai une erreur:
Pourtant j'ai bien regardé l'exemple, lu ce qu'il y avait et la du coup, je ne saisie pas pourquoi ça ne se connecte pas, parce qu'il le prend apparament pour autre chose.
Merci pour vos réponses,
Nos....
Alors j'ai quelque peu réécris mon script en essayant d'utiliser une "fonction" global, ce qui donne :
TCL
# CONFIGURATION MySQL:
set ::MySQL(HOSTNAME) "localhost"
set ::MySQL(USERNAME) "xxxxxx"
set ::MySQL(PASSWORD) "xxxxxxxxxx"
set ::MySQL(DATABASE) "db"
set ::MySQL(PORT) "3306"
# Connection MySQL:
package require mysqltcl
set ::MySQL(Handle) [mysqlconnect -host $::MySQL(HOSTNAME) -user $::MySQL(USERNAME) -password $::MySQL(PASSWORD) -port $::MySQL(PORT) -db $::MySQL(DATABASE)]
# CONFIGURATION canal et bots:
set chan1 "test1"
set chan2 "test2"
set bots "Excalibur"
# CONFIGURATION commande:
bind pub - !search search
proc search { nick uhost hand chan arg } {
set args [string map [list "*" "%" " " "%"] $arg];
set articles [mysqlsel $::MySQL(Handle) "SELECT `reference`, `articles` FROM `db` WHERE `articles` LIKE '%$args%' ORDER BY `articles` DESC LIMIT 5" -flatlist]
if {$articles == ""} {
putquick "PRIVMSG $chan2 :Aucun résultat."
} elseif {$articles != ""} {
foreach {reference articles} $articles {
putquick "PRIVMSG $chan2 :${reference} ${articles}"
}
foreach { bot } [split $::bots " "] {
putbot $bot "::search ${reference} ${articles}"
}
}
mysqlclose $::MySQL(Handle);
}
# CONFIGURATION pour le botnet:
bind bot - ::search bot:search
proc bot:search { from_bot cmd text } {
global chan1 chan2
set args [split $text " "]
set reference [lindex $args 0]
set articles [lindex $args 1]
foreach { chan } [split $chan2 " "] {
putquick "PRIVMSG $chan2 :${reference} ${article}"
}
}
Mais voila il y a un mais quand je le lance, dans la party line j'ai une erreur:
Citation :Tcl error [search]: bad variable name "mysql(Handle)": upvar won't create a scalar variable that looks like an array element
Pourtant j'ai bien regardé l'exemple, lu ce qu'il y avait et la du coup, je ne saisie pas pourquoi ça ne se connecte pas, parce qu'il le prend apparament pour autre chose.
Merci pour vos réponses,
Nos....