- private:
- OperPrefixMode* opm;
- public:
- ModuleOperPrefixMode(InspIRCd* Me) : Module(Me)
- {
- ConfigReader Conf(ServerInstance);
- std::string tmp;
- tmp = Conf.ReadValue("operprefix", "prefix", "!", 0, false);
- strlcpy(&prefixchar,tmp.c_str(),2);
-
- opm = new OperPrefixMode(ServerInstance);
- if ((!ServerInstance->Modes->AddMode(opm)))
- throw ModuleException("Could not add a new mode!");
-
- Implementation eventlist[] = { I_OnPostJoin, I_OnCleanup, I_OnUserQuit, I_OnUserKick, I_OnUserPart, I_OnOper };
- ServerInstance->Modules->Attach(eventlist, this, 6);
- }
-
- virtual void PushChanMode(Channel* channel, User* user, bool negate = false)
- {
- if (negate)
- DelPrefixChan(user, channel);
- else
- AddPrefixChan(user, channel);
- char modeline[]="+y";
- if (negate)
- modeline [0]='-';
- std::vector<std::string> modechange;
- modechange.push_back(channel->name);
- modechange.push_back(modeline);
- modechange.push_back(user->nick);
- ServerInstance->SendMode(modechange,this->ServerInstance->FakeClient);
- }
-
- virtual void OnPostJoin(User *user, Channel *channel)
- {
- // This may look wrong, but I don't think it is.. PushChanMode will send FMODE which should sort it all out.
- if (!IS_LOCAL(user))
- return;
-
- if (user && IS_OPER(user))
- {
- if (user->IsModeSet('H'))
- {
- /* we respect your wish to be invisible */
- return;
- }
- PushChanMode(channel, user);
- }
- }