I've made this script which is running under Eggdrop v1.6.21, but I can't get it to start. The error I'm receiving is:
Tcl error in file 'eggdrop.conf':
wrong # args: should be "proc name args body"
while executing
"proc logit {nick host handle channel text} {
What could be the problem? This is my script.
package require mysqltcl
set port {3306}
set host {127.0.0.1}
set user {database_user}
set password {database_password}
set db {database_name}
bind pubm - "*" logit
proc logit {nick uhost handle channel text} {
global port
global host
global user
global password
global db
if {[string match {database_name}} $channel] == 0} {
set mysql_handler [mysqlconnect -host $host -port $port -user $user -password $password -db $db]
set sql "insert into irc_feed (nickname, host, message) values ('[mysqlescape $nick]', '[mysqlescape $uhost]', '[mysqlescape $text]')"
mysqlexec $mysql_handler $sql
mysqlclose $mysql_handler
}
}
Thank you very much.
The problem is in the if
condition: there is an extra }
after {database_name}
. It leads to the body of the procedure being closed too early, and the body of the if
command becomes an unintended extra argument to proc
(and the very last closing brace becomes an invalid command).
This could be called a parse-time error. If an error makes it all the way to execution (a run-time error) Tcl usually knows enough about the situation to produce a better error message.
At this point though, all the Tcl interpreter knows is that it is trying to execute a command with three arguments, and it has been given four. Hence, the error message is very vague.
However, when a "wrong # args" error is signaled, one has usually either inserted white-space in a place where it shouldn't be, or the braces don't match up. A brace-matching editor is very useful in the latter case.