proc auth {nick hand host txt} {
global botnick ci cf db mainchan mainchanpvt modeauth
if { $modeauth == 1 } {
if {[onchan $nick $mainchan]} {
if { [::mysql::sel $db "SELECT auth FROM users WHERE ircnick='[string tolower $nick]' AND ircstatus='1'"] == "1" } {
puthelp "PRIVMSG $nick :$ci Tu já estas autenticado! $cf"
} else {
set auth [string tolower [lindex [split $txt] 0]]
set pass [md5 [string tolower [lindex [split $txt] 1]]]
if { $txt == "" } {
puthelp "PRIVMSG $nick :$ci Comando inválido, para te autenticares usa /msg $botnick auth <nick> <pass> $cf"
} else {
if { $pass == "" } {
puthelp "PRIVMSG $nick :$ci Comando inválido, para te autenticares usa /msg $botnick auth <nick> <pass> $cf"
} else {
if {[::mysql::sel $db "SELECT password FROM users WHERE auth='$auth'" -list] == $pass } {
set check [::mysql::sel $db "SELECT ircstatus FROM users WHERE auth='$auth'" -list]
if { $check == 1 } {
set authednick [::mysql::sel $db "SELECT ircnick FROM users WHERE auth='$auth'" -list]
putserv "privmsg $authednick :$ci O utilizador $nick fez auth na tua conta(#$auth). Deixas-te de estar autenticado $cf"
}
set result [::mysql::exec $db "UPDATE users SET ircstatus='1' WHERE auth='$auth'"]
set result [::mysql::exec $db "UPDATE users SET ircnick='$nick' WHERE auth='$auth'"]
set level [::mysql::sel $db "SELECT level FROM users WHERE auth='$auth'" -list]
puthelp "PRIVMSG $nick :$ci Estás agora autenticado como $auth $cf"
set auth [::mysql::sel $db "SELECT auth FROM users WHERE ircnick='$nick' AND ircstatus='1'" -list]
}
} else {
putserv "privmsg $mainchanpvt : Tentativa de login falhado por $nick (Auth: #$auth)"
puthelp "PRIVMSG $nick :$ci Password/nick inválido, para te autenticares usa /msg $botnick auth <nick> <pass> $cf"
}
}
}
}
} else {
puthelp "PRIVMSG $nick :$ci Precisas de estar no canal $mainchan para fazer auth $cf"
}
} else {
puthelp "PRIVMSG $nick :$ci Esta funcão foi desactivada $cf"
}
}
( I deleted some code, maybe a } is missing or smthng.)
That proc checks if your on the chan, checks if your already authed, checks if your login/password exists and also checks if they match acording to de mysql db.
Ahh, I do see some unbalanced {}'s but that's probably due to your trimming.
The error at hand however, is that you use the -list option with ::mysql::sel. This makes it return a tcl-list of results, and you'll have to use lindex to retrieve a single item, or join to convert the list into a string.
#This...
if {[::mysql::sel $db "SELECT password FROM users WHERE auth='$auth'" -list] == $pass } {
#Should be changed into this...
if {[join [::mysql::sel $db "SELECT password FROM users WHERE auth='$auth'" -list]] == $pass } {
#This...
set check [::mysql::sel $db "SELECT ircstatus FROM users WHERE auth='$auth'" -list]
#Should be changed into this...
set check [join [::mysql::sel $db "SELECT ircstatus FROM users WHERE auth='$auth'" -list]]
#And so on...