| View previous topic :: View next topic |
| Author |
Message |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Sun Nov 16, 2008 9:25 am Post subject: Variables |
|
|
removed
Last edited by garfwen on Thu Jun 28, 2012 2:19 am; edited 2 times in total |
|
| Back to top |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Sun Nov 16, 2008 9:30 am Post subject: |
|
|
| ouh... the help texts are in Portuguese but I dont think its necessary to translate :\ |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Sun Nov 16, 2008 9:54 am Post subject: |
|
|
Simple, you create $forum and $site in global space. You may reference them as $forum and $site only when used in global space. If your using them within local space (inside of a procedure) you must add them as global variables in the global line, or reference them as $::forum and $::site. _________________ speechles' eggdrop tcl archive |
|
| Back to top |
|
 |
garfwen Halfop
Joined: 12 Mar 2008 Posts: 61
|
Posted: Sun Nov 16, 2008 10:06 am Post subject: |
|
|
Yeah !
It's working now.
Ty |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Sun Nov 16, 2008 10:20 am Post subject: |
|
|
I do see a few flaws in your script. The first issue at hand is that you don't take variable-spaces into considderation. Variables created in globalspace generally cannot be accessed as local variables within a proc (except unless they've explicitly been linked to a local variable using upvar or global). Hence, you cannot use $globalvar within your proc to access the globalspace variable globalvar, use $::globalvar instead (or use the global command to link it to the localspace variable.
The second issue is that you named one of your parameters "args" in holm-join_greet raw:qauth. This name has a special meaning, and should be avoided unless you explicitly desire this behaviour ("args", when used as the last parameter in a proc declaration, may accept 0 or more arguments, concatenating them into a tcl-list).
Third issue is that you keep mixing lists and strings in a way that will cause your script to malfunction under certain conditions. Commands such as lindex expect a list, not a string, and will not operate correctly if the provided data is not a valid tcl-list structure.
This piece of code pretty much sums up all the above, and I'll add comments explaining the flaws and how to correct them..
| Code: | bind raw - 311 raw:qauth
#Proc has been declared with an "args" parameter, yet the raw binding always calls the proc with a fixed number of arguments.. Hence, args will be a tcl-list with one list-item containing all that the server sent us...
proc raw:qauth {from keyword args} {
global Qauth Qpass Qhost
#Since args is a list, we have to use join to convert it into a string. Using a different parameter name would save us from this extra work...
set args [string tolower [join $args]]
#But now, we've already converted args into a string, we can't use list operations on it, such as lindex...
#Even if we hadn't joined args into a string, you'd still have problems, as the initial list only had one list item containing the whole string, and all you'd end up with is having nick = "" and host = "@".
#What you need to do, is convert the string into a list. split usually does the trick here, and it also allows you to specify which character (default space) should be used to "split" upon.
set nick [lindex $args 1]
set host "[lindex $args 2]@[lindex $args 3]"
if {$host == [string tolower $Qhost]} {
puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"
#Here we try to read the local variable gatherbot, yet it has not been declared anywhere within the proc, thus this will throw an error and abort execution...
#Most likely, you were trying to access the globalspace variable with the same name. To do this, you'd either have to use the global command, or use a full path to the variable ($::gatherbot)
puthelp "PRIVMSG $gatherbot :AUTH"
}
}
### The proper code should look something like this instead:
bind raw - 311 raw:qauth
proc raw:qauth {from keyword text} {
global Qauth Qpass Qhost
set ltext [split $text]
set nick [lindex $ltext 1]
set host "[lindex $ltext 2]@[lindex $ltext 3]"
#I am using a slightly different way of comparing the hosts, saving me alot of case mangling.
if {[string equal -nocase $host $Qhost]} {
puthelp "PRIVMSG Q@CServe.quakenet.org :AUTH $Qauth $Qpass"
puthelp "PRIVMSG $::gatherbot :AUTH"
}
}
|
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
|
|
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
|
|