Code: Select all
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: Select all
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..