| View previous topic :: View next topic |
| Author |
Message |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Mon Sep 24, 2007 5:05 pm Post subject: Voice Script |
|
|
Hi all
i have this piece of code that is a part of a Voice script.
| Code: | 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. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Mon Sep 24, 2007 5:20 pm Post subject: |
|
|
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: | | 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: | | matchattr [nick2hand $N $C] "-q&-q" $C |
_________________ NML_375, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Mon Sep 24, 2007 8:29 pm Post subject: |
|
|
| nml375 wrote: | Use "matchattr" to test wether a user has a given flag:
| Code: | | 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: |
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.
================================== |
|
| Back to top |
|
 |
honeybee Halfop
Joined: 01 Jan 2006 Posts: 80
|
Posted: Mon Sep 24, 2007 9:04 pm Post subject: |
|
|
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' |
|
| Back to top |
|
 |
awyeah Revered One

Joined: 26 Apr 2004 Posts: 1580 Location: Switzerland
|
Posted: Mon Sep 24, 2007 9:13 pm Post subject: |
|
|
Thanks honeybee. _________________ ·awyeah·
==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
================================== |
|
| Back to top |
|
 |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Tue Sep 25, 2007 1:34 am Post subject: |
|
|
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: | | if {[onchan $N $C] && ![isvoice $N $C]} { |
by this line :
| Code: | | if {[onchan $N $C] && ![isvoice $N $C] && ![matchattr [nick2hand $N $C] q|q $C]} { |
and it s working, thanks again. |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 25, 2007 11:56 am Post subject: |
|
|
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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Tue Sep 25, 2007 2:53 pm Post subject: |
|
|
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 |
|
| Back to top |
|
 |
nml375 Revered One
Joined: 04 Aug 2006 Posts: 2857
|
Posted: Tue Sep 25, 2007 3:17 pm Post subject: |
|
|
You should be able to use "getchanmode" for this, along with "string match" and some "gluecode"
I'd suggest something like this:
| Code: | | 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, idling at #eggdrop@IrcNET |
|
| Back to top |
|
 |
Zircon Op
Joined: 21 Aug 2006 Posts: 191 Location: Montreal
|
Posted: Tue Sep 25, 2007 7:50 pm Post subject: |
|
|
Thanks a lot nml375, it worked perfectly  |
|
| Back to top |
|
 |
|