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.

detect user flags

Help for those learning Tcl or writing their own scripts.
Post Reply
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

detect user flags

Post by Koach »

I have looked hard for the answer to this and can't find it. But, I am sure it's going to be a simple solution.

I am trying to write a simple script that will only accept input from users that have channel flag +o.
The input must be sent via a PRIVMSG. The user might or might not be actually opped (channel mode +o) when they send the PRIVMSG, but they will be in the channel and IDENT'd to the bot.

I know I can do something like this:

bind msg o|o qban msg:qban

and then:

proc msg:qban {nick host handle stuff} {
code here
}

But, as I understand it, that won't really test the channel flag for the nick.

I can easily extract the channel name and user name from the string in "stuff" but, how can I test the users nick for channel flags?

Am I missing something obvious?

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

Post by nml375 »

Actually, I think you're looking at the wrong kind of binding..
msg bindings are used for user-to-user messages, not user-to-channel messages. As such, there is no channel information related to the message.

Or were you thinking of forcing the user to supply the channel name in the message? If so, extract the channel from the message, and use the matchattr command to test the privileges.

As for the flags-mask, the syntax is "globalflags[(&|)[channelflags[(&|)botflags]]]", where & specifies that all flags must match, and | any flag will be sufficient. For applications that does not provide a channelname, the channelflags part is tested against any/all channels.

A few examples of different "flag-masks". I've used bindings here, but they could easily be swapped for the matchattr command (msg binding would be equivalent of omitting the channel argument, pub would be including it).

Code: Select all

bind msg o msg:test
#Triggers for any global op.

bind msg o|o msg:test2
#Triggers for any global op, and any local op in any channel

bind pub o pub:test
#Triggers for any global op.

bind pub o|o pub:test2
#Triggers for any global op, and any local op in the channel it's invoked within.

bind pub o&o pub:test3
#Triggers for any user who is both a global op and a local op for the channel it's invoked within.

bind pub fp| pub:test4
#Triggers for any global friend or partyline access user.

bind pub fp& pub:test5
#Triggers for any user with both global op and partyline access.
Reading your post a second time, I believe this is what you are looking for:

Code: Select all

bind msg o|o qban msg:qban
proc msg:qban {nick host handle stuff} {
 ... extracting chan and storing it in $chan...

 if {![matchattr $handle "o&o" $chan]} {
  #User does not have permission for this command, abort
  return 0
 }
 
... Rest of code here...
}
NML_375
K
Koach
Voice
Posts: 21
Joined: Sun Apr 19, 2009 6:42 pm
Contact:

Post by Koach »

That's exactly what I was looking for :)

Thanks
Post Reply