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.

Voice Script

Help for those learning Tcl or writing their own scripts.
Post Reply
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Voice Script

Post by Zircon »

Hi all

i have this piece of code that is a part of a Voice script.

Code: Select all

proc AV_V {N C c} {
  global av_M
  if {$av_M($c) == 0} {return 0}
  if {[onchan $N $C] && ![isvoice $N $C]} {
    putquick "MODE $C +v $N"
  }
  return 0
}
I want to modify this proc so the script won't voice a user that has a global or channel q flag. By the way : q flag means "quiet" user (user cannot gain voice)

Thanks in advance.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Use "matchattr" to test wether a user has a given flag or combination of flags.
The following should be "true" if the user has neither global or channel-speciffic q:

Code: Select all

matchattr $handle "-q&-q" $channel
Now, since you did not post the full script, you'll have to figure out how to get the handle and channel. I would guess $C is the channel, and $N is the nickname to be voiced, and in this case you could use nick2hand to get the handle:

Code: Select all

matchattr [nick2hand $N $C] "-q&-q" $C
NML_375
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

nml375 wrote:Use "matchattr" to test wether a user has a given flag:

Code: Select all

matchattr [nick2hand $N $C] "-q&-q" $C
Never knew it could be done in this way possible using a "&" with a "-" infront of both flags. All I know is to use it in this way:

Code: Select all

if {![matchattr [nick2hand $nick $chan] q|q $chan]} {
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
h
honeybee
Halfop
Posts: 80
Joined: Sun Jan 01, 2006 12:42 pm

Post by honeybee »

it should work properly it will be only 0 when "-q" for both global & channel.
this type of flag matching is mentioned in '.help match'
User avatar
awyeah
Revered One
Posts: 1580
Joined: Mon Apr 26, 2004 2:37 am
Location: Switzerland
Contact:

Post by awyeah »

Thanks honeybee.
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hi all

Thanks for your help nml375 and awyeah. Since i dont want to voice a user that have q global flag OR q channel flag, i replaced this line :

Code: Select all

if {[onchan $N $C] && ![isvoice $N $C]} { 
by this line :

Code: Select all

if {[onchan $N $C] && ![isvoice $N $C] && ![matchattr [nick2hand $N $C] q|q $C]} {
and it s working, thanks again.
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

Well, either should work just fine, as they produce exactly the same result. Which one you use is just a matter of what you find most intuitive.
NML_375
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Hello nml375

Thanks for yur help, and indeed, you are right about the intuitive thing. I need to add a new condition now before voicing a user. I dont want the script to voice anyone when the channel is on mode "D", case sensitive. What to do to test that mode "D" is one of the channels modes at that time ?

Thans in advance
n
nml375
Revered One
Posts: 2860
Joined: Fri Aug 04, 2006 2:09 pm

Post by nml375 »

You should be able to use "getchanmode" for this, along with "string match" and some "gluecode"
I'd suggest something like this:

Code: Select all

string match "*D*" [lindex [split [getchanmode $C]] 0]
This extracts the first part of the channelmode, getting rid of any channelkey and/or limit, then does a simple match to see wether there is a capital D within the remaining string. If there is, it will return true.
In your case, you would probably like to negate it, as shown earlier posts.
NML_375
Z
Zircon
Op
Posts: 191
Joined: Mon Aug 21, 2006 4:22 am
Location: Montreal

Post by Zircon »

Thanks a lot nml375, it worked perfectly :)
Post Reply