ModuleOperPrefixMode()
: opm(this), hideoperwatcher(this)
, hideopermode(this, "hideoper")
- {
- }
-
- void init() CXX11_OVERRIDE
{
/* To give clients a chance to learn about the new prefix we don't give +y to opers
* right now. That means if the module was loaded after opers have joined channels
* they need to rejoin them in order to get the oper prefix.
*/
-
- ServerInstance->Modes->AddModeWatcher(&hideoperwatcher);
}
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
modechange.push_back(user->nick);
for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++)
{
- modechange[0] = (*v)->name;
+ modechange[0] = (*v)->chan->name;
ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient);
}
}
SetOperPrefix(user, true);
}
-
- ~ModuleOperPrefixMode()
- {
- ServerInstance->Modes->DelModeWatcher(&hideoperwatcher);
- }
-
Version GetVersion() CXX11_OVERRIDE
{
return Version("Gives opers cmode +y which provides a staff prefix.", VF_VENDOR);
void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string& parameter, bool adding)
{
- if (IS_LOCAL(dest))
+ // If hideoper is being unset because the user is deopering, don't set +y
+ if (IS_LOCAL(dest) && dest->IsOper())
parentmod->SetOperPrefix(dest, !adding);
}