X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_namedmodes.cpp;h=2fbdca26561856ca5ecc29ac6ae66b12a73d9248;hb=5a2af6ded883d71c6c4c9f1497cca1721f8b0742;hp=9c7b24666eeba64a270be87855d885357cb3ac84;hpb=0de5aa7c5cfff6d2389f1adcc41d6b2deeec2bc4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 9c7b24666..2fbdca265 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -19,27 +19,36 @@ #include "inspircd.h" +enum +{ + // InspIRCd-specific. + RPL_ENDOFPROPLIST = 960, + RPL_PROPLIST = 961 +}; + static void DisplayList(LocalUser* user, Channel* channel) { - std::stringstream items; + Numeric::ParamBuilder<1> numeric(user, RPL_PROPLIST); + numeric.AddStatic(channel->name); + const ModeParser::ModeHandlerMap& mhs = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL); for (ModeParser::ModeHandlerMap::const_iterator i = mhs.begin(); i != mhs.end(); ++i) { ModeHandler* mh = i->second; if (!channel->IsModeSet(mh)) continue; - items << " +" << mh->name; - if (mh->GetNumParams(true)) + numeric.Add("+" + mh->name); + ParamModeBase* pm = mh->IsParameterMode(); + if (pm) { - if ((mh->name == "key") && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex"))) - items << " "; + if ((pm->IsParameterSecret()) && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex"))) + numeric.Add("<" + mh->name + ">"); else - items << " " << channel->GetModeParameter(mh); + numeric.Add(channel->GetModeParameter(mh)); } } - const std::string line = ":" + ServerInstance->Config->ServerName + " 961 " + user->nick + " " + channel->name; - user->SendText(line, items); - user->WriteNumeric(960, channel->name, "End of mode list"); + numeric.Flush(); + user->WriteNumeric(RPL_ENDOFPROPLIST, channel->name, "End of mode list"); } class CommandProp : public SplitCommand @@ -48,15 +57,15 @@ class CommandProp : public SplitCommand CommandProp(Module* parent) : SplitCommand(parent, "PROP", 1) { - syntax = " {[+-] []}*"; + syntax = " [[(+|-)] []]"; } - CmdResult HandleLocal(const std::vector& parameters, LocalUser* src) + CmdResult HandleLocal(LocalUser* src, const Params& parameters) CXX11_OVERRIDE { Channel* const chan = ServerInstance->FindChan(parameters[0]); if (!chan) { - src->WriteNumeric(Numerics::NoSuchNick(parameters[0])); + src->WriteNumeric(Numerics::NoSuchChannel(parameters[0])); return CMD_FAILURE; } @@ -79,7 +88,7 @@ class CommandProp : public SplitCommand ModeHandler* mh = ServerInstance->Modes->FindMode(prop, MODETYPE_CHANNEL); if (mh) { - if (mh->GetNumParams(plus)) + if (mh->NeedsParam(plus)) { if (i != parameters.size()) modes.push(mh, plus, parameters[i++]); @@ -102,7 +111,7 @@ class DummyZ : public ModeHandler } // Handle /MODE #chan Z - void DisplayList(User* user, Channel* chan) + void DisplayList(User* user, Channel* chan) CXX11_OVERRIDE { if (IS_LOCAL(user)) ::DisplayList(static_cast(user), chan); @@ -120,10 +129,10 @@ class ModuleNamedModes : public Module Version GetVersion() CXX11_OVERRIDE { - return Version("Provides the ability to manipulate modes via long names.",VF_VENDOR); + return Version("Provides the ability to manipulate modes via long names", VF_VENDOR); } - void Prioritize() + void Prioritize() CXX11_OVERRIDE { ServerInstance->Modules->SetPriority(this, I_OnPreMode, PRIORITY_FIRST); } @@ -160,7 +169,7 @@ class ModuleNamedModes : public Module } curr.param.clear(); - if (mh->GetNumParams(curr.adding)) + if (mh->NeedsParam(curr.adding)) { if (value.empty()) {