* Originally by Chernov-Phoenix Alexey (Phoenix@RusNet) mailto:phoenix /email address separator/ pravmail.ru
*/
-/* $ModDesc: Gives opers cmode +y which provides a staff prefix. */
-
#include "inspircd.h"
#define OPERPREFIX_VALUE 1000000
{
OperPrefixMode opm;
HideOperWatcher hideoperwatcher;
+ UserModeReference hideopermode;
public:
ModuleOperPrefixMode()
: opm(this), hideoperwatcher(this)
+ , hideopermode(this, "hideoper")
{
}
{
ServerInstance->Modules->AddService(opm);
- Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper };
- ServerInstance->Modules->Attach(eventlist, this, sizeof(eventlist)/sizeof(Implementation));
-
/* 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.
ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE
{
- if ((user->IsOper()) && (user->IsModeSet('H')))
+ if ((user->IsOper()) && (!user->IsModeSet(hideopermode)))
privs.push_back('y');
return MOD_RES_PASSTHRU;
}
{
std::vector<std::string> modechange;
modechange.push_back("");
- modechange.push_back(add ? "+y" : "-y");
+ modechange.push_back(add ? "+" : "-");
+ modechange[1].push_back(opm.GetModeChar());
modechange.push_back(user->nick);
for (UCListIter v = user->chans.begin(); v != user->chans.end(); v++)
{
modechange[0] = (*v)->name;
- ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient);
+ ServerInstance->Modes->Process(modechange, ServerInstance->FakeClient);
}
}
void OnPostOper(User* user, const std::string& opername, const std::string& opertype) CXX11_OVERRIDE
{
- if (IS_LOCAL(user) && (!user->IsModeSet('H')))
+ if (IS_LOCAL(user) && (!user->IsModeSet(hideopermode)))
SetOperPrefix(user, true);
}