| View previous topic :: View next topic |
| Author |
Message |
dlpt Voice
Joined: 18 Sep 2009 Posts: 4
|
Posted: Fri May 07, 2010 7:09 am Post subject: Error in my tcl |
|
|
need help in my tcl.
| Code: | proc whois { nick uhost hand chan arg }
global color1 color2 bd_user bd_pass bd_host bd_dbase bd_table
set bd [::mysql::connect -host $bd_host -user $bd_user -password $bd_pass]
if { $login_ok == 1 } {
set sd [::mysql::whois $db "SELECT username, level FROM $db_table" -list]
foreach wl $sd {
if { $wl != "" } {
set wl_split [split $wl]
set user_name [lindex $wl_split 0]
set user_level [lindex $wl_split 2]
putquick "privmsg $chan :$color1 $n $color2$color1 Info level $user_level $color2"
}
if { $login_ok == 0 } {
putquick "privmsg $chan :$color1 dont cry. $color2" |
I try ON eggdrop and:
| Code: | [12:02] wrong # args: should be "proc name args body"
while executing
"proc whois { nick uhost hand arg }"
(file "scripts/test.tcl" line 12)
|
Any idea ? |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri May 07, 2010 8:40 am Post subject: |
|
|
Seems to be indicating that whatever calls/triggers the proc provides/requires a different number of arguments than are accounted for in the proc definition.
For one thing, your proc says this :-
| Code: |
proc whois { nick uhost hand chan arg }
|
But your error says this :-
| Code: |
proc whois { nick uhost hand arg }
|
We need to see what triggers it to be more help. Looks like some sort of Eggdrop Tcl BIND. _________________ I must have had nothing to do |
|
| Back to top |
|
 |
dlpt Voice
Joined: 18 Sep 2009 Posts: 4
|
Posted: Fri May 07, 2010 9:33 am Post subject: |
|
|
sorry, error lol, the code are:
| Code: | set bd_user "fxp_egg"
set bd_pass "password"
set bd_host "localhost"
set bd_dbase "fxp_test"
set bd_table "users"
bind msgm - "*" auth
bind pub - !whois whois
#####Code by tomekk
proc auth { nick uhost hand arg } {
global msql_user msql_pass msql_host msql_dbase msql_table invite_chan color1 color2 adminchannel
set all_prv_args [split $arg]
set priv_command [lindex $all_prv_args 0]
set priv_username [lindex $all_prv_args 1]
set priv_password [lindex $all_prv_args 2]
set login_ok 0
if {($priv_command == "auth") && ($priv_username != "") && ($priv_password != "")} {
set m_hand [::mysql::connect -host $msql_host -user $msql_user -password $msql_pass]
::mysql::use $m_hand $msql_dbase
set users_passwords [::mysql::sel $m_hand "SELECT username, password FROM $msql_table" -list]
::mysql::close $m_hand
foreach u_and_p $users_passwords {
if {$u_and_p != ""} {
set u_and_p_split [split $u_and_p]
set user_name [lindex $u_and_p_split 0]
set user_pass [lindex $u_and_p_split 1]
if {$priv_username == $user_name} {
if {$priv_password == $user_pass} {
set login_ok 1
putquick "privmsg $nick :$color1 Login ok! $color2"
}
}
}
}
if {$login_ok == 0} {
putquick "PRIVMSG $nick :$color1 Login ERROR! $color2"
}
}
}
#####End code by Tomekk####
proc whois { nick uhost hand chan arg }
global color1 color2 bd_user bd_pass bd_host bd_dbase bd_table
set bd [::mysql::connect -host $bd_host -user $bd_user -password $bd_pass]
if { $login_ok == 1 } {
set sd [::mysql::whois $db "SELECT username, level FROM $db_table" -list]
foreach wl $sd {
if { $wl != "" } {
set wl_split [split $wl]
set user_name [lindex $wl_split 0]
set user_level [lindex $wl_split 2]
putquick "privmsg $chan :$color1 $n $color2$color1 Info level $user_level $color2"
}
if { $login_ok == 0 } {
putquick "privmsg $chan :$color1 dont cry. $color2" |
I record via the database users and meto the desired level
Table:
| Code: | create table users (
id int(4) auto_increment,
username varchar(12),
password varchar(12),
level varchar(12),
primary key(id)
); |
btw, you could do me the code to record starting at php and give the automatic level one . A kind of small php script to log in
dlpt,
thanks |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri May 07, 2010 9:57 am Post subject: |
|
|
I assume you corrected the original error, since the whois proc has the required number of arguments for a PUB bind. I would avoid using 'arg' as an argument variable name because it is uncomfortably close to 'args' which has special meaning in Tcl. The generally accepted norm is to use 'text' or 'rest'.
Sorry, it's a very long time since I did any php. it would be like learning all over again. In any case this would not be the right forum for php script requests. _________________ I must have had nothing to do |
|
| Back to top |
|
 |
dlpt Voice
Joined: 18 Sep 2009 Posts: 4
|
Posted: Fri May 07, 2010 10:09 am Post subject: |
|
|
the error continues :s
| Code: | [15:06] Tcl error in file 'myegg.conf':
[15:06] wrong # args: should be "proc name args body"
while executing
"proc whois { nick uhost hand chan txt }"
(file "scripts/test.tcl" line 54)
invoked from within
"source scripts/test.tcl"
(file "myegg.conf" line 1310)
[15:06] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
|
I do not understand why
| Code: | set bd_user "fxp_egg"
set bd_pass "password"
set bd_host "localhost"
set bd_dbase "fxp_test"
set bd_table "users"
bind msgm - "*" auth
bind pub - !whois whois
#####Code by tomekk#####
proc auth { nick uhost hand arg } {
global msql_user msql_pass msql_host msql_dbase msql_table invite_chan color1 color2 adminchannel
set all_prv_args [split $arg]
set priv_command [lindex $all_prv_args 0]
set priv_username [lindex $all_prv_args 1]
set priv_password [lindex $all_prv_args 2]
set login_ok 0
if {($priv_command == "auth") && ($priv_username != "") && ($priv_password != "")} {
set m_hand [::mysql::connect -host $msql_host -user $msql_user -password $msql_pass]
::mysql::use $m_hand $msql_dbase
set users_passwords [::mysql::sel $m_hand "SELECT username, password FROM $msql_table" -list]
::mysql::close $m_hand
foreach u_and_p $users_passwords {
if {$u_and_p != ""} {
set u_and_p_split [split $u_and_p]
set user_name [lindex $u_and_p_split 0]
set user_pass [lindex $u_and_p_split 1]
if {$priv_username == $user_name} {
if {$priv_password == $user_pass} {
set login_ok 1
putquick "privmsg $nick :$color1 Login ok! $color2"
}
}
}
}
if {$login_ok == 0} {
putquick "PRIVMSG $nick :$color1 Login ERROR! $color2"
}
}
}
#####End code by Tomekk####
proc whois { nick uhost hand chan txt }
global color1 color2 bd_user bd_pass bd_host bd_dbase bd_table
set bd [::mysql::connect -host $bd_host -user $bd_user -password $bd_pass]
if { $login_ok == 1 } {
::mysql::use $db $msql_dbase
set sd [::mysql::whois $db "SELECT username, level FROM $db_table" -list]
::mysql::close $db
foreach wl $sd {
if { $wl != "" } {
set wl_split [split $wl]
set user_name [lindex $wl_split 0]
set user_level [lindex $wl_split 2]
putquick "privmsg $chan :$color1 $n $color2$color1 Info level $user_level $color2"
}
}
}
if { $login_ok == 0 } {
putquick "privmsg $chan :$color1 dont cry. $color2"
} |
Hm, ok, I'll see if I learn.
dlpt,
Thanks
Last edited by dlpt on Fri May 07, 2010 10:16 am; edited 1 time in total |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri May 07, 2010 10:16 am Post subject: |
|
|
Missing opening brace :-
| Code: |
proc whois { nick uhost hand chan txt }
|
Should be :-
| Code: |
proc whois {nick uhost hand chan txt} {
|
I have also removed the unnecessary spaces preceding and following the proc arguments. _________________ I must have had nothing to do |
|
| Back to top |
|
 |
dlpt Voice
Joined: 18 Sep 2009 Posts: 4
|
Posted: Fri May 07, 2010 10:20 am Post subject: |
|
|
Now another error -.-'
| Code: | [15:20] missing close-brace
while executing
"proc whois {nick uhost hand chan txt} {
global color1 color2 bd_user bd_pass bd_host bd_dbase bd_table
if { $login_ok == 1 } {
set m_h..."
(file "scripts/test.tcl" line 54)
invoked from within
"source scripts/test.tcl"
(file "myegg.conf" line 1310) |
any idea ?  |
|
| Back to top |
|
 |
arfer Master

Joined: 26 Nov 2004 Posts: 436 Location: Manchester, UK
|
Posted: Fri May 07, 2010 10:35 am Post subject: |
|
|
I think you need to get yourself a syntax aware editor. The code is a bit of a mess.
Issues like the following can lead to 'false' errors, such as the one you have encountered.
I can't really understand how you managed to load the script, let alone get errors
Since Tomekk wouldn't write such rubbish, I can only assume you are editing somebody else's code and don't have a clue what you are doing
Use of undefined variable n :-
| Code: |
putquick "privmsg $chan :$color1 $n $color2$color1 Info level $user_level $color2"
|
Use of undefined variable db (bd is defined, did you mean that) :-
| Code: |
set sd [::mysql::whois $db "SELECT username, level FROM $db_table" -list]
|
Use of undefined variable db_table (bd_table is defined, did you mean that) :-
| Code: |
set sd [::mysql::whois $db "SELECT username, level FROM $db_table" -list]
|
Use of undefined variable login_ok :-
| Code: |
if { $login_ok == 1 } {
|
Missing close brace to conclude the following foreach statement :-
Missing close braces to conclude one or both of the following :-
| Code: |
if { $login_ok == 0 } {
if { $login_ok == 1 } {
|
_________________ I must have had nothing to do |
|
| Back to top |
|
 |
tomekk Master

Joined: 28 Nov 2008 Posts: 255 Location: Oswiecim / Poland
|
|
| Back to top |
|
 |
|