egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Error in my tcl

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
dlpt
Voice


Joined: 18 Sep 2009
Posts: 4

PostPosted: Fri May 07, 2010 7:09 am    Post subject: Error in my tcl Reply with quote

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri May 07, 2010 8:40 am    Post subject: Reply with quote

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
View user's profile Send private message
dlpt
Voice


Joined: 18 Sep 2009
Posts: 4

PostPosted: Fri May 07, 2010 9:33 am    Post subject: Reply with quote

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri May 07, 2010 9:57 am    Post subject: Reply with quote

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
View user's profile Send private message
dlpt
Voice


Joined: 18 Sep 2009
Posts: 4

PostPosted: Fri May 07, 2010 10:09 am    Post subject: Reply with quote

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 Embarassed

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
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri May 07, 2010 10:16 am    Post subject: Reply with quote

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
View user's profile Send private message
dlpt
Voice


Joined: 18 Sep 2009
Posts: 4

PostPosted: Fri May 07, 2010 10:20 am    Post subject: Reply with quote

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 ? Smile
Back to top
View user's profile Send private message
arfer
Master


Joined: 26 Nov 2004
Posts: 436
Location: Manchester, UK

PostPosted: Fri May 07, 2010 10:35 am    Post subject: Reply with quote

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 :-

Code:

foreach wl $sd {


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
View user's profile Send private message
tomekk
Master


Joined: 28 Nov 2008
Posts: 255
Location: Oswiecim / Poland

PostPosted: Sat May 08, 2010 7:57 am    Post subject: Reply with quote

i will just add to this post,

the code between marks "#####Code by tomekk#####" is not the same like mine from:
http://forum.egghelp.org/viewtopic.php?t=16547
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber