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 

Voice Script

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Scripting Help
View previous topic :: View next topic  
Author Message
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Mon Sep 24, 2007 5:05 pm    Post subject: Voice Script Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Mon Sep 24, 2007 5:20 pm    Post subject: Reply with quote

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
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Mon Sep 24, 2007 8:29 pm    Post subject: Reply with quote

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
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
honeybee
Halfop


Joined: 01 Jan 2006
Posts: 80

PostPosted: Mon Sep 24, 2007 9:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
awyeah
Revered One


Joined: 26 Apr 2004
Posts: 1580
Location: Switzerland

PostPosted: Mon Sep 24, 2007 9:13 pm    Post subject: Reply with quote

Thanks honeybee.
_________________
·­awyeah·

==================================
Facebook: jawad@idsia.ch (Jay Dee)
PS: Guys, I don't accept script helps or requests personally anymore.
==================================
Back to top
View user's profile Send private message Send e-mail Visit poster's website Yahoo Messenger MSN Messenger
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Tue Sep 25, 2007 1:34 am    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Sep 25, 2007 11:56 am    Post subject: Reply with quote

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
View user's profile Send private message
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Tue Sep 25, 2007 2:53 pm    Post subject: Reply with quote

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
View user's profile Send private message
nml375
Revered One


Joined: 04 Aug 2006
Posts: 2857

PostPosted: Tue Sep 25, 2007 3:17 pm    Post subject: Reply with quote

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
View user's profile Send private message
Zircon
Op


Joined: 21 Aug 2006
Posts: 191
Location: Montreal

PostPosted: Tue Sep 25, 2007 7:50 pm    Post subject: Reply with quote

Thanks a lot nml375, it worked perfectly Smile
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 -> Scripting Help 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