[Résolu] moderation SQL
#13
Oui, tu as ajouté un truc et pas revu ton TCL.

Je te dis d'ajouter un count(), qui te permet d'avoir toujours un résultat et donc de ne pas avoir à faire ta boucle: soit nb = 0 et le mot n'est pas présent soit nb > 0 et le mot est présent.

Voici à quoi devrait ressembler ton script si tu avais tout lu / suivi:
tcl
#Proc - Badword #
bind pub o|o .+badword +badword
proc +badword { nick host hand chan arg } {
	set colonne(mots) [string tolower [lindex $arg 0]]
	set colonne(salon) [lindex $arg 1]
	if ![onchan $nick $::back(chan)] {
		putserv "notice $nick :\00314Erreur vous devez être sur\003 \0034$::back(chan)\0034"
		return
	}
	if {$colonne(mots)==""} {
		putserv "notice $nick :\00314Incorrect veuillez mettre un mot\003. Exemple : .+badword \0034connard #salon\0034"
		return 0
	}
	if {![string match #* $colonne(salon)]} {
		putserv "notice $nick :\00314Incorrect veuillez mettre un salon\003. Exemple : \0034#SQL\0034"
		return 0
	}
	service:connect
	set res [mysqlsel $::mysqlink "SELECT count(*) FROM `badword` WHERE mots='$colonne(mots)' and salon='$colonne(salon)'" -list]
	set nb [lindex $res 0]
	service:deconnect
	if {$nb >= 1} {
		putserv "notice $nick :\00314Mot invalide ! le mot\003 (\0034$colonne(mots)\0031) et déjà enregistré sur le salon !"
		return 0
	}
	service:connect
	mysqlsel $::mysqlink "INSERT INTO badword (mots, salon) VALUES ('$colonne(mots)', '$colonne(salon)')"
	service:deconnect
	puthelp "privmsg $::back(chan) :$::chanlog(+badword) \00314Sur\003 \0034$chan\0034 \0031\002$hand@$nick\002\0031 (\0037$colonne(mots)\0031)"
}


Répondre


Messages dans ce sujet
moderation SQL - par aliasangelius - 07/03/2017, 12:51
RE: moderation SQL - par CrazyCat - 07/03/2017, 13:59
RE: moderation SQL - par aliasangelius - 07/03/2017, 14:08
RE: moderation SQL - par aliasangelius - 07/03/2017, 17:57
RE: moderation SQL - par CrazyCat - 08/03/2017, 00:53
RE: moderation SQL - par aliasangelius - 08/03/2017, 14:42
RE: moderation SQL - par CrazyCat - 08/03/2017, 16:47
RE: moderation SQL - par aliasangelius - 08/03/2017, 17:42
RE: moderation SQL - par CrazyCat - 08/03/2017, 18:37
RE: moderation SQL - par aliasangelius - 08/03/2017, 19:24
RE: moderation SQL - par CrazyCat - 09/03/2017, 01:06
RE: moderation SQL - par aliasangelius - 09/03/2017, 01:27
RE: moderation SQL - par CrazyCat - 09/03/2017, 13:00
RE: moderation SQL - par aliasangelius - 09/03/2017, 15:45
RE: moderation SQL - par CrazyCat - 10/03/2017, 00:48
RE: moderation SQL - par aliasangelius - 10/03/2017, 14:43

Atteindre :


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