the second script is used as "!gline nick time reason"
it can easily be modified to have a default time in case one is not given
as for "which one is good?"; neither is good, however, both work
DragnLord wrote:the second script is used as "!gline nick time reason"
it can easily be modified to have a default time in case one is not given
as for "which one is good?"; neither is good, however, both work
DragnLord, sorry to say this, but neither of your scripts work. See my previous posts for details on how they're broken.
DragnLord wrote:the second script is used as "!gline nick time reason"
it can easily be modified to have a default time in case one is not given
as for "which one is good?"; neither is good, however, both work
DragnLord, sorry to say this, but neither of your scripts work. See my previous posts for details on how they're broken.
both scripts worked on my ircds when tested, thank you very much
Unrealircd accepts nicknames OR hostname/ip as the target
the second script works even if only nick is provided (on Unrealircd)
the ircd then uses it's configured default time for the g:line with the requestor's handle as reason if none is given
although joining reason fixes the reason not being whole if there are spaces
(edit: I only tested script with single word reasons, that's why scripts should not be written before coffee....lol)
bind pub G !gline pub:gline
proc pub:gline {n u h c t} {
set nick "[lindex $t 0]"
set time "[lindex $t 1]"
set reason "[lrange $t 2 end]"
putserv "gline $nick $time :$reason ($h)"
}
Sloppy, very very sloppy.. not a good way to teach beginners or those wishing to pick up habits from other tcl scripters. This is how you should do it..
set nick "[lindex [split $t] 0]"
set time "[lindex [split $t] 1]"
set reason "[join [lrange [split $t] 2 end]]"
nml375 is only trying to help you, not ridicule you, neither am I. Just showing you that others will pick up your (bad) habit and unexpected consequences often arise with tcl special characters when treating strings as lists and vice versa.
As said by speechles, my intention of pointing out errors/flaws is to help people improve their coding. Just as I hope/expect ppl to point out errors I've made.
For some odd reason, it is (almost) always easier to see other peoples errors than one's own..
splitting $t a second time is quite unneeded as it is already separated by spaces, no need to use split here (TCL already defaults to using the spaces as separators)
it's more of a "bad habit" to do unneeded things, at least in my opinion
thank you for pointing out the global variable error, my ircd configuration uses 1440 as default, so I didn't catch that one
DragnLord wrote:splitting $t a second time is quite unneeded as it is already separated by spaces, no need to use split here (TCL already defaults to using the spaces as separators)
it's more of a "bad habit" to do unneeded things, at least in my opinion
thank you for pointing out the global variable error, my ircd configuration uses 1440 as default, so I didn't catch that one
Your forgetting your using unsanitized user input . I can use {[]} (nicknames allow these, don't they?) in my input and I've just broken your script (splitting would've kept this from happening).... these are the unexpected consequences that I mentioned happening with tcl special characters.
Splitting a second time?
I think you are abit confused 'bout splitting...
Split converts a string to a list, $t is a string since it originates from the binding. Hence it should (must) be splitted prior being used with any commands expecting a list as a parameter. Using your code with a "reason" such as "evil user typing {" would illustrate how your script was broken, and how split is necessary.
A bad habit, in my opinion, is not bothering to keep track whether the content of a variable is a string or a list (always considder user input to be a string, never a list).
speechles wrote:Your forgetting your using unsanitized user input . I can use {[]} (nicknames allow these, don't they?) in my input and I've just broken your script (splitting would've kept this from happening).... these are the unexpected consequences that I mentioed happening with tcl special characters.
true enough, special characters may present issues, although on my tests with nicknames that included braces it still worked
as I said earlier, coding before coffee is baaaad