0

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.

4

1 回答 1

4

问题在于if条件:有一个额外的}after {database_name}。它导致过程的主体过早关闭,并且if命令的主体变成了一个意外的额外参数proc(并且最后一个右大括号变成了无效的命令)。

这可以称为解析时错误。如果错误一直导致执行(运行时错误),Tcl 通常对情况有足够的了解以产生更好的错误消息。

不过此时,Tcl 解释器所知道的只是它正在尝试执行一个带有三个参数的命令,而它已经被赋予了四个参数。因此,错误消息非常模糊。

但是,当发出“错误的#args”错误信号时,通常要么在不应该的地方插入空格,要么大括号不匹配。大括号匹配编辑器在后一种情况下非常有用。

于 2017-08-11T09:00:19.497 回答