X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_namedmodes.cpp;h=7a86c9e3cffb4a44700592c19332ae83e261fd69;hb=19f0c09aa783cc3b945c880d509c1da8bc8e0275;hp=617ee43b368f5a3f6f48e588e4ab15ea5f227b35;hpb=0b63ccd0b5cb26883d6becb196fb98e4f95d0397;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 617ee43b3..7a86c9e3c 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -19,43 +19,45 @@ #include "inspircd.h" -static void DisplayList(User* user, Channel* channel) +static void DisplayList(LocalUser* user, Channel* channel) { - std::stringstream items; + Numeric::ParamBuilder<1> numeric(user, 961); + 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); + if (mh->NeedsParam(true)) { if ((mh->name == "key") && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex"))) - items << " "; + numeric.Add(""); 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, "%s :End of mode list", channel->name.c_str()); + numeric.Flush(); + user->WriteNumeric(960, channel->name, "End of mode list"); } -class CommandProp : public Command +class CommandProp : public SplitCommand { public: - CommandProp(Module* parent) : Command(parent, "PROP", 1) + CommandProp(Module* parent) + : SplitCommand(parent, "PROP", 1) { syntax = " {[+-] []}*"; } - CmdResult Handle(const std::vector ¶meters, User *src) + CmdResult HandleLocal(const std::vector& parameters, LocalUser* src) { Channel* const chan = ServerInstance->FindChan(parameters[0]); if (!chan) { - src->WriteNumeric(ERR_NOSUCHNICK, "%s :No such nick/channel", parameters[0].c_str()); + src->WriteNumeric(Numerics::NoSuchNick(parameters[0])); return CMD_FAILURE; } @@ -78,7 +80,7 @@ class CommandProp : public Command 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++]); @@ -103,7 +105,8 @@ class DummyZ : public ModeHandler // Handle /MODE #chan Z void DisplayList(User* user, Channel* chan) { - ::DisplayList(user, chan); + if (IS_LOCAL(user)) + ::DisplayList(static_cast(user), chan); } }; @@ -158,7 +161,7 @@ class ModuleNamedModes : public Module } curr.param.clear(); - if (mh->GetNumParams(curr.adding)) + if (mh->NeedsParam(curr.adding)) { if (value.empty()) {