X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_operprefix.cpp;h=7d5e6d1181151f0cfae5c7b243205fed2d910248;hb=a5d110282a864fd2e91b51ce360a977cd0643657;hp=25937cd6ea27cbc91b8c0dff4ac6e26bf7df9867;hpb=0a8b0d317ed4adc43185c1b791bcf752115dc58e;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index 25937cd6e..7d5e6d118 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -58,6 +58,39 @@ class OperPrefixMode : public ModeHandler } bool NeedsOper() { return true; } + + void RemoveMode(Channel* chan, irc::modestacker* stack) + { + irc::modestacker modestack(false); + const UserMembList* users = chan->GetUsers(); + for (UserMembCIter i = users->begin(); i != users->end(); ++i) + { + if (i->second->hasMode(mode)) + { + if (stack) + stack->Push(this->GetModeChar(), i->first->nick); + else + modestack.Push(this->GetModeChar(), i->first->nick); + } + } + + if (stack) + return; + + std::deque stackresult; + std::vector mode_junk; + mode_junk.push_back(chan->name); + while (modestack.GetStackedLine(stackresult)) + { + mode_junk.insert(mode_junk.end(), stackresult.begin(), stackresult.end()); + ServerInstance->SendMode(mode_junk, ServerInstance->FakeClient); + mode_junk.erase(mode_junk.begin() + 1, mode_junk.end()); + } + } + + void RemoveMode(User* user, irc::modestacker* stack) + { + } }; class ModuleOperPrefixMode; @@ -85,7 +118,7 @@ class ModuleOperPrefixMode : public Module { ServerInstance->Modules->AddService(opm); - Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule }; + Implementation eventlist[] = { I_OnUserPreJoin, I_OnPostOper, I_OnLoadModule, I_OnUnloadModule, I_OnPostJoin }; 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 @@ -110,6 +143,22 @@ class ModuleOperPrefixMode : public Module return MOD_RES_PASSTHRU; } + void OnPostJoin(Membership* memb) + { + if ((!IS_LOCAL(memb->user)) || (!IS_OPER(memb->user)) || (((mw_added) && (memb->user->IsModeSet('H'))))) + return; + + if (memb->hasMode(opm.GetModeChar())) + return; + + // The user was force joined and OnUserPreJoin() did not run. Set the operprefix now. + std::vector modechange; + modechange.push_back(memb->chan->name); + modechange.push_back("+y"); + modechange.push_back(memb->user->nick); + ServerInstance->SendGlobalMode(modechange, ServerInstance->FakeClient); + } + void SetOperPrefix(User* user, bool add) { std::vector modechange; @@ -162,7 +211,8 @@ class ModuleOperPrefixMode : public Module void HideOperWatcher::AfterMode(User* source, User* dest, Channel* channel, const std::string& parameter, bool adding, ModeType type) { - if (IS_LOCAL(dest)) + // If hideoper is being unset because the user is deopering, don't set +y + if (IS_LOCAL(dest) && IS_OPER(dest)) parentmod->SetOperPrefix(dest, !adding); }