This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

script to autovoice nicks that ends with letter z

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
a
asdd1
Voice
Posts: 23
Joined: Sat Jul 05, 2008 6:33 am

script to autovoice nicks that ends with letter z

Post by asdd1 »

Hi folks,

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.
User avatar
BLaCkShaDoW
Op
Posts: 118
Joined: Sun Jan 11, 2009 4:50 am
Location: Romania
Contact:

Hello :)

Post by BLaCkShaDoW »

This should work

Code: Select all

##################################################################
#
# VoiceNick 
#
#just activate using .chanset #channel +voicenick
#
#
##################################################################

setudef flag voicenick
bind join - * checknick
bind nick - * changenick


proc checknick {nick host hand chan} {
if {![validchan $chan]} { return 0 }
if {[channel get $chan voicenick]} {
if {[string match -nocase "*z" "$nick"] || [string match -nocase "*Z" "$nick"]} {
pushmode $chan +v $nick
}
}
}

proc changenick {nick host hand chan newnick} {
if {![validchan $chan]} { return 0 }
if {[channel get $chan voicenick]} {
if {[isvoice $newnick $chan]} {
if {![string match "*z" $newnick] || ![string match "*Z" $newnick]} {
pushmode $chan -v $newnick
}
}
}
}
putlog "VoiceNick by BLaCkShaDoW Loaded"
BLaCkShaDoW Production @ WwW.TclScripts.Net
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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:

Code: Select all

if {!([string match "*z" $newnick] || [string match "*Z" $newnick])} {
#Or this one..
if {![string match "*z" $newnick] && ![string match "*Z" $newnick]} {
NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

Code: Select all

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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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.
NML_375
User avatar
speechles
Revered One
Posts: 1398
Joined: Sat Aug 26, 2006 10:19 pm
Location: emerald triangle, california (coastal redwoods)

Post by speechles »

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.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

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* ;)
NML_375
m
mr_fanatic
Voice
Posts: 11
Joined: Fri Aug 31, 2007 4:04 am

Guest kick

Post by mr_fanatic »

i modify the above code so that when a users nick change to Guest7834 or Guest???? it will devoice them. but it doesnt work. please help.

Code: Select all

setudef flag voicenick
bind nick - * guestchangenick 
proc guestchangenick {nick host hand chan newnick} {
  if {![channel get $chan voicenick]} { return }
  if {!([string match "Guest*" $newnick] || [string match "Guest*" $newnick])} { 
	pushmode $chan -v $nick
  }
}
putlog "Guest Devoice loaded"
m
mr_fanatic
Voice
Posts: 11
Joined: Fri Aug 31, 2007 4:04 am

Fixed: Guest Devoice

Post by mr_fanatic »

Okay, after several trial and errors i've finally manage to make it work :P. For users interested usage is: .chanset #channel +guestdevoice

Code: Select all

setudef flag guestdevoice
bind nick - * guestchangenick 
proc guestchangenick {nick host hand chan newnick} {
	if {![channel get $chan guestdevoice]} { return } 
	if {[isvoice $newnick $chan]} {
		if {[string match "Guest*" $newnick]} {
			pushmode $chan -v $newnick
		}
	}
} 
putlog "Guest Devoice loaded."
Post Reply