after weeks of googling and trying different combinations with the code, i'm out of ideas and need your help
i'm using a simple script to invite users to a channel using the MySQL db..
user sends his password and username in exchange for a channel invite
it all works nice, until db pings out (after 8 hours) and then the following msg is shown in the bot's log
Code: Select all
Tcl error [inv_1]: mysqlsel/db server: MySQL server has gone away
Code: Select all
package require mysqltcl
set dbuser "myDB_user"
set dbpassword "myDB_password"
set name "myDB_name"
set db_handle [mysqlconnect -host localhost -socket /var/run/mysqld/mysqld.sock -user $dbuser -password $dbpassword -db $name]
set userchan "#myChan"
bind msg - !invite inv_1
proc inv_1 { nick uhost handle arg } {
global userchan db_handle
set arg [split $arg " "]
set user1 [lindex $arg 0]
set user1 [string range $user1 0 end]
set pass1 [lindex $arg 1]
set pass1 [string range $pass1 0 end]
if { $user1 == "" || $pass1 == "" } {
putserv "privmsg $nick :Use: !invite <username> <irc-key>"
return 0
}
mysqlping $db_handle
set sql "SELECT irckey FROM users WHERE username='[mysqlescape $user1]'"
set result [mysqlsel $db_handle $sql -list]
if {$result > 0} {
set record [lindex $result 0];
set pass [lindex $record 0];
if {$pass1 == $pass} {
putserv "NOTICE $nick :Welcome :)"
putserv "invite $nick $userchan"
} else {
puthelp "NOTICE $nick :Wrong password!"
}
} else {
puthelp "NOTICE $nick :Your username ($user1) was not found in our records."
}
mysqlendquery $db_handle
}
if not, would it be wise to rehash the bot every 8 hours? (and how to do that?)