virtual void OnJoin(const CNick& Nick, CChan& Channel) {
// If we have ops in this chan
if (Channel.HasPerm(CChan::Op)) {
[...]
If you mean user in the "some random guy in #channel"-sense instead of the "some znc user"-sense:
// Check if "peter" has op in CChannl& chan
CNick *pPeter = chan.FindNick("peter");
if (!pPeter) {
// "peter" is not in that channel
} else if (!pPeter->HasPerm('o') {
// "peter" doesn't have op
} else {
// "peter got op"
}
(This is untested and I just came up with it, but it should (hopefully) work)
You can't use CNick::HasPerm() on a CNick passed in via a module call since that instance is only initialized with the hostmask, not the nick's permissions.
Cheers,
psychon
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks for that - works perfect! I'm using both snipplets in a module to cancel out if either myself is not (half-)opped or the user is (half-)opped (in OnChanMsg):
With creating modules, is there an easy way to determine whether a user has Op/HalfOp/Voice status in a channel?
Thanks.
Example from autoop.cpp line 160:
virtual void OnJoin(const CNick& Nick, CChan& Channel) {
// If we have ops in this chan
if (Channel.HasPerm(CChan::Op)) {
[...]
If you mean user in the "some random guy in #channel"-sense instead of the "some znc user"-sense:
// Check if "peter" has op in CChannl& chan
CNick *pPeter = chan.FindNick("peter");
if (!pPeter) {
// "peter" is not in that channel
} else if (!pPeter->HasPerm('o') {
// "peter" doesn't have op
} else {
// "peter got op"
}
(This is untested and I just came up with it, but it should (hopefully) work)
You can't use CNick::HasPerm() on a CNick passed in via a module call since that instance is only initialized with the hostmask, not the nick's permissions.
Cheers,
psychon
I just noticed that it might be HasPerm('@') instead of HasPerm('o')....
Thanks for that - works perfect! I'm using both snipplets in a module to cancel out if either myself is not (half-)opped or the user is (half-)opped (in OnChanMsg):
if (!Channel.HasPerm('o') && !Channel.HasPerm('h') && !Channel.HasPerm('@') && !Channel.HasPerm('%'))
return CONTINUE;
CNick* chkNick = Channel.FindNick(Nick.GetNick());
if (chkNick->HasPerm('o') || chkNick->HasPerm('h') || chkNick->HasPerm('@') || chkNick->HasPerm('%'))
return CONTINUE;
I initially didn't read your last reply, thus experienced problems when using HasPerm('o'). But all now is well!
Thanks again.