namespace eval dbCheck {
set dbInfo "host user pass database"
bind join - "#channel *" [namespace current]::dbJoin
proc dbJoin {nick uhost handle chan} {
if {[isbotnick $nick]} return
variable dbInfo
if {[scan $dbInfo %s%s%s%s hostname username password database] != 4} return
set con [::mysql::connect -host $hostname -user $username -password $password -db $database]
set results [::mysql::query $con "INSERT YOUR SELECT STATEMENT"]
if {![::mysql::moreresult $results]} {
# kick, ban or whatever
}
::mysql::endquery $results
::mysql::close $con
}
}
Something like this? Don't forget to add an actual select statement and a punishment or whatever you wish. Haven't tested it, but should do what you where looking for.
caesar,
Whenever you inject data from an untrusted source, you should use mysql_real_escape_string (::mysql::escape in mysqltcl) in order to avoid SQL injection exploits. Although the MySQL driver does not enable the multiple statement extension by default, you could still bypass the WHERE-clause of your query (generally speaking, irc nicknames and hostnames do not support spaces making it rather difficult to exploit "OR 1" here).
As such, escaping the nickname is correct, though you should do the very same for the hostname.