X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_namedmodes.cpp;h=f25cc219ca18a455bbea93f0ba1dbdcd8a6f9947;hb=f3f2388a81b6463e1229fa5bf2b8c427440bf406;hp=1735df924298c4bdb70e5a6ef4d19574a5dc09ef;hpb=6fe1f4e1136f2ab95a88e68af1894bf6002d03f4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_namedmodes.cpp b/src/modules/m_namedmodes.cpp index 1735df924..f25cc219c 100644 --- a/src/modules/m_namedmodes.cpp +++ b/src/modules/m_namedmodes.cpp @@ -1,6 +1,11 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2017 B00mX0r + * Copyright (C) 2013-2016 Attila Molnar + * Copyright (C) 2013, 2017-2019 Sadie Powell + * Copyright (C) 2012, 2019 Robby + * Copyright (C) 2010 Craig Edwards * Copyright (C) 2009-2010 Daniel De Graaf * * This file is part of InspIRCd. InspIRCd is free software: you can @@ -19,38 +24,53 @@ #include "inspircd.h" -static void DisplayList(User* user, Channel* channel) +enum { - std::stringstream items; + // InspIRCd-specific. + RPL_ENDOFPROPLIST = 960, + RPL_PROPLIST = 961 +}; + +static void DisplayList(LocalUser* user, Channel* channel) +{ + 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)) - items << " " << channel->GetModeParameter(mh); + numeric.Add("+" + mh->name); + ParamModeBase* pm = mh->IsParameterMode(); + if (pm) + { + if ((pm->IsParameterSecret()) && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex"))) + numeric.Add("<" + mh->name + ">"); + else + 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(RPL_ENDOFPROPLIST, 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 = " {[+-] []}*"; + syntax = " [[(+|-)] []]"; } - CmdResult Handle(const std::vector ¶meters, User *src) + CmdResult HandleLocal(LocalUser* src, const Params& parameters) CXX11_OVERRIDE { 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::NoSuchChannel(parameters[0])); return CMD_FAILURE; } @@ -64,6 +84,8 @@ class CommandProp : public Command while (i < parameters.size()) { std::string prop = parameters[i++]; + if (prop.empty()) + continue; bool plus = prop[0] != '-'; if (prop[0] == '+' || prop[0] == '-') prop.erase(prop.begin()); @@ -71,7 +93,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++]); @@ -94,9 +116,11 @@ class DummyZ : public ModeHandler } // Handle /MODE #chan Z - void DisplayList(User* user, Channel* chan) + void DisplayList(User* user, Channel* chan) CXX11_OVERRIDE { - ::DisplayList(user, chan); + LocalUser* luser = IS_LOCAL(user); + if (luser) + ::DisplayList(luser, chan); } }; @@ -111,10 +135,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 support for adding and removing modes via their long names.", VF_VENDOR); } - void Prioritize() + void Prioritize() CXX11_OVERRIDE { ServerInstance->Modules->SetPriority(this, I_OnPreMode, PRIORITY_FIRST); } @@ -151,7 +175,7 @@ class ModuleNamedModes : public Module } curr.param.clear(); - if (mh->GetNumParams(curr.adding)) + if (mh->NeedsParam(curr.adding)) { if (value.empty()) {