X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_operprefix.cpp;h=7d5e6d1181151f0cfae5c7b243205fed2d910248;hb=ccd4c11ea1a43d079eaae9708482ef4a9148796c;hp=b6e6b893b73481ee801cdb741fccb3f848b881a9;hpb=84a1569cd60daa64b1ae52a1fff62c0dc4d78850;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_operprefix.cpp b/src/modules/m_operprefix.cpp index b6e6b893b..7d5e6d118 100644 --- a/src/modules/m_operprefix.cpp +++ b/src/modules/m_operprefix.cpp @@ -51,13 +51,46 @@ class OperPrefixMode : public ModeHandler return MODEACTION_ALLOW; else { - if (source && channel) + if (channel) source->WriteNumeric(ERR_CHANOPRIVSNEEDED, "%s %s :Only servers are permitted to change channel mode '%c'", source->nick.c_str(), channel->name.c_str(), 'y'); return MODEACTION_DENY; } } 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); }