egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

script to autovoice nicks that ends with letter z

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
asdd1
Voice


Joined: 05 Jul 2008
Posts: 23

PostPosted: Wed Aug 26, 2009 6:04 am    Post subject: script to autovoice nicks that ends with letter z Reply with quote

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.
Back to top
View user's profile Send private message
BLaCkShaDoW
Op


Joined: 11 Jan 2009
Posts: 115
Location: Romania

PostPosted: Wed Aug 26, 2009 10:25 am    Post subject: Hello :) Reply with quote

This should work

Code:
##################################################################
#
# 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
Back to top
View user's profile Send private message Send e-mail Visit poster's website
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Aug 26, 2009 12:24 pm    Post subject: Reply with quote

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:
if {!([string match "*z" $newnick] || [string match "*Z" $newnick])} {
#Or this one..
if {![string match "*z" $newnick] && ![string match "*Z" $newnick]} {

_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Aug 26, 2009 5:29 pm    Post subject: Reply with quote

Code:
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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Aug 26, 2009 5:39 pm    Post subject: Reply with quote

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, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Wed Aug 26, 2009 5:57 pm    Post subject: Reply with quote

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 Wink

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.
_________________
speechles' eggdrop tcl archive
Back to top
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Wed Aug 26, 2009 6:17 pm    Post subject: Reply with quote

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* Wink
_________________
NML_375, idling at #eggdrop@IrcNET
Back to top
View user's profile Send private message
mr_fanatic
Voice


Joined: 31 Aug 2007
Posts: 11

PostPosted: Wed Aug 26, 2009 7:00 pm    Post subject: Guest kick Reply with quote

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:
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"
Back to top
View user's profile Send private message
mr_fanatic
Voice


Joined: 31 Aug 2007
Posts: 11

PostPosted: Wed Aug 26, 2009 7:21 pm    Post subject: Fixed: Guest Devoice Reply with quote

Okay, after several trial and errors i've finally manage to make it work Razz. For users interested usage is: .chanset #channel +guestdevoice
Code:
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."
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
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


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber