I been trying to make a tcl script which can fecth info from a vbulletin dbase through a public command. But somehow the information doesnt get relayed to my irc channel.
This is what the bot says on the partyline:
[15:14] Userinfo: executing SELECT userid,posts FROM `user` WHERE username='Repec'
[15:14] test query19 (just added for testing)
And this is the script im using:
Code: Select all
load /usr/local/lib/tcl8.3/mysqltcl/libmysqltcl.so.2
#####################################
# DATABASE VARIABLES #
#####################################
set db(host) "localhost"
set db(username) "tralala"
set db(password) "secret"
set db(database) "mydbase"
set db(socket) "/var/lib/mysql/mysql.sock"
#####################################
# CONNECT TO DATABASE #
#####################################
set db_handle [mysqlconnect -host $db(host) -user $db(username) -password $db(password) -db $db(database) -socket $db(socket)]
#####################################
# BINDS #
#####################################
bind pub - !user pub_userlookup
#####################################
# CODE STARTS HERE #
#####################################
set app(version) "14-8-2004 4:21PM"
proc pub_userlookup { nick uhost hand chan text} {
global db_handle
set sUsername [lindex $text 0]
set sql "SELECT userid,posts,Stros,Races,Scans,Hacks,requestsfilled FROM `user` WHERE username='$sUsername'"
putlog "Userinfo: executing $sql"
set result [mysqlquery $db_handle $sql]
putlog "test $result" <-- is just for testing
if {[set row [mysqlnext $result]] != ""} {
set userid [lindex $row 0]
set posts [lindex $row 1]
putserv "PRIVMSG $chan: User stats for \002$sUsername\002: \[Posts: $posts \]"
} else {
putserv "PRIVMSG $chan :Couldn't find userinfo"
}
mysqlendquery $result
}
Thx in advance
/Repec