| View previous topic :: View next topic |
| Author |
Message |
LB_1981 Voice
Joined: 08 Jun 2009 Posts: 15
|
Posted: Fri Jun 26, 2009 3:04 pm Post subject: Help please |
|
|
Hi can someone help me with this
| Code: | proc cmd:tempshun {nick uhost hand arg} {
set nick [lindex [split $arg] 0]
set reason [lrange [split $arg] 1 end]
putserv "TEMPSHUN $nick :$reason"
putserv "PRIVMSG #CWStats Tempshun Added To $nick (Reason) $reason"
} |
Is what i need it to do is message #cwstats with Tempshun Added To $nick by $username (Reason) $reason. need another set option which is for $username but am not sure how to add the extra set the above code works fine just need that extra set
need a small change to this one also
| Code: | proc cmd:tempakill {nick uhost hand args} {
set args [join $args]
set username [lindex $args 0]
set reason [lrange $args 1 end]
putserv "GLINE $username :$reason"
putserv "PRIVMSG #CWStats Temporary GLINE added to $username (Reason) $reason"
} |
is what im trying to get this to do is the same as above
Tempgline Added To $nick by $username (Reason) $reason and also set it so it glines for 4 hours this code also works just need to add the two extras
many thanks _________________ LB_1981 |
|
| Back to top |
|
 |
username Op

Joined: 06 Oct 2005 Posts: 196 Location: Russian Federation, Podolsk
|
Posted: Fri Jun 26, 2009 5:18 pm Post subject: |
|
|
| Code: | proc cmd:tempshun {nick uhost hand arg} {
set victim [lindex [split $arg] 0]
set reason [lrange [split $arg] 1 end]
putserv "TEMPSHUN $nick :$reason"
putserv "PRIVMSG #CWStats :Tempshun Added To $victim by $nick (Reason) $reason"
} |
This is wrong code: | Code: | set args [join $args]
set username [lindex $args 0] |
You cant use lindex in string. Lindex for lists only.
And you neednt use join with $args, because $args already a string.
| Code: | proc cmd:tempakill {nick uhost hand args} {
set victim [lindex [split $args] 0]
set reason [lrange [split $args] 1 end]
putserv "GLINE $victim :$reason"
putserv "PRIVMSG #CWStats :Temporary GLINE added to $victim by $nick (Reason) $reason"
} |
And dont forget about : in putserv. It looks like this: putserv "Type Destination :Text"
Where Type can be PRIVMSG or NOTICE
Destination can be Nick or Chan and
Text is text to send to. _________________ Архив TCL скриптов для ботов Eggdrop/Windrop:
http://egghelp.ru/ |
|
| Back to top |
|
 |
speechles Revered One

Joined: 26 Aug 2006 Posts: 1398 Location: emerald triangle, california (coastal redwoods)
|
Posted: Fri Jun 26, 2009 6:59 pm Post subject: |
|
|
| Code: | proc cmd:tempakill {nick uhost hand args} {
set args [join $args]
set username [lindex $args 0]
set reason [lrange $args 1 end]
putserv "GLINE $username :$reason"
putserv "PRIVMSG #CWStats Temporary GLINE added to $username (Reason) $reason"
} |
This entire code is incorrect, everything except the first putserv, the second is incorrect and will never message the channel intended. It is missing the seperating (space)colon after target nick/channel in the PRIVMSG, it simply has the (space)...
| Code: | proc cmd:tempakill {nick uhost hand arg} {
set username [lindex [split $arg] 0]
set reason [join [lrange [split $arg] 1 end]]
putserv "GLINE $username :$reason"
putserv "PRIVMSG #CWStats :Temporary GLINE ($reason -> $username) by $nick."
} |
Now let me explain the subtle differences here....
Notice first off, I've removed your line 2.. and my code is 6 lines versus your 7. Now let's move onto bigger things...
# The proc header, aka, the first line of code
You never want to make the mistake of using "args" within your procedure header unless it is invoked by several binds/procedures using differing amounts of arguments. If you don't understand what that means then use "text" or "arg" or literally anything else instead. The reason for this you don't need to understand, but "args" is a reserved word when used within a procedure header. It allows for a variable number of arguments to be passed through the procedure without declaring each argument individually. These arguments are then passed to the procedure as a list. A procedure that is bound to PUB or MSG input will always have a static number of arguments passed making your use of $args in this case very inappropriate. You are having to use more code to return the list $args give you back into a string, and work around this issue than it would be to correctly build your procedure header.
# The lindex, aka line 2...
The problem here isn't quite as obvious. Since you have used $args to catch the text of the user you were given a list. But you then used [join $args] to return this to a string. Then you attempt to lindex this string before turning it into a list...But since we need to solve the problem of line 1 first, it is better to [split $arg] and then lindex properly on a list. Never use list commands on strings. Golden rule #1 - section 1
# The lrange, aka line 3...
The problem here has the same qualities as number 2. But.. There is a big difference here. Lrange will return a list, not a string like lindex will. Because of this you will need to [join] your lrange back into a string, or risk curly bracings appearing when displaying any contents containing special characters. Doing it correctly special tcl characters never effect your script. Golden rule #1 - section 2
# The solution, aka advice for life...
follow all the steps above and this time listen. Follow the golden rules (all your issues are discussed here: lindex, lrange, and args). Treat these golden rules as "tcl law" and correct your flawed use of $args and pretend that it is equivalent to typing .die in your bot. Just forget it exists unless you want to kill your eggdrop..  _________________ speechles' eggdrop tcl archive |
|
| 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
|
|