I've googled and checked the archive, but haven't been able to locate a TCL script for our little eggdrop which will auto voice nicks on entry to a room.
The catch is that nicks which should be auto-voiced should only be those that have a last letter z or Z... And devoice user, if user changes nick that doesn't have last letter z OR Z..
Any help or pointers would be truly appreciated.
I'm afraid that the logic for the nick-change is flawed, and it will always de-voice on nickchange. However, if you stick with the -nocase option, there's no need to test both cases.
If you'd like to leave out the -nocase option for compability with older versions of tcl, use one of these logic patterns instead:
if {!([string match "*z" $newnick] || [string match "*Z" $newnick])} {
#Or this one..
if {![string match "*z" $newnick] && ![string match "*Z" $newnick]} {
setudef flag voicenick
bind join - * zchecknick
bind nick - * zchangenick
proc zchecknick {nick host hand chan} {
if {![channel get $chan voicenick]} { return }
if {[string equal -nocase "z" [string index $nick end]]} {
pushmode $chan +v $nick
}
}
proc zchangenick {nick host hand chan newnick} {
if {![channel get $chan voicenick]} { return }
if {![string equal -nocase "z" [string index $newnick end]]} {
pushmode $chan -v $nick
} elseif {![isvoice $newnick $chan]} {
pushmode $chan +v $nick
}
}
What about if the nick "jimbob" changes nick to "jimbobz" shouldn't he then be voiced? The above script is much easier on the eyes and is indented properly. For some reason this blackshadow guy can't write clear coherent code with proper indentation to save his life. I'm not sure if this is intentional or caused by some improper editor of his mangling prefixed spacing.
That [valid $chan] part is not necessary as the [channel get] will not be set if the channel isn't valid.. Remember you can't set an invalid channel any settings.
Also, changed the procedure names to avoid collisions with any other scripts which may use those all-to-common procedure names.
Probably right on the nickchange, speechles.
Performance-wize, I'd suggest you use string match, as this saves you one command call. Which approach is the "cleanest" is something I'll leave up to anyone to decide on their own.
nml375 wrote:Probably right on the nickchange, speechles.
Performance-wize, I'd suggest you use string match, as this saves you one command call. Which approach is the "cleanest" is something I'll leave up to anyone to decide on their own.
Performance-wize ... You are quite the sharp mind nml, purposely mispelling it to fit the topic
And yeah, your probably correct in that if you merely used a single [string match] but your using two.. heh so yours will be slower. I was trying to show the poster there are several methods to do this without resulting to glob string match for everything. It shows him how to extract the last letter in case he wants to do something further down the road.
Well... I did mention the two cases of using -nocase vs not using it (in the post where I did post code).
Of course, any performance comparisons should be done under similar conditions apart from the very function you are testing... though now we're getting rather academic :p
Ps. did a very limited "time" test... guess what, my code ran faster *nag*