]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_namedmodes.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / modules / m_namedmodes.cpp
index cd63f42985de9de1b1aa3ff75a22872d6c886473..f25cc219ca18a455bbea93f0ba1dbdcd8a6f9947 100644 (file)
@@ -1,6 +1,11 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2017 B00mX0r <b00mx0r@aureus.pw>
+ *   Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2013, 2017-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2010 Craig Edwards <brain@inspircd.org>
  *   Copyright (C) 2009-2010 Daniel De Graaf <danieldg@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
 
 #include "inspircd.h"
 
+enum
+{
+       // InspIRCd-specific.
+       RPL_ENDOFPROPLIST = 960,
+       RPL_PROPLIST = 961
+};
+
 static void DisplayList(LocalUser* user, Channel* channel)
 {
-       Numeric::ParamBuilder<1> numeric(user, 961);
+       Numeric::ParamBuilder<1> numeric(user, RPL_PROPLIST);
        numeric.AddStatic(channel->name);
 
        const ModeParser::ModeHandlerMap& mhs = ServerInstance->Modes->GetModes(MODETYPE_CHANNEL);
@@ -31,16 +43,17 @@ static void DisplayList(LocalUser* user, Channel* channel)
                if (!channel->IsModeSet(mh))
                        continue;
                numeric.Add("+" + mh->name);
-               if (mh->NeedsParam(true))
+               ParamModeBase* pm = mh->IsParameterMode();
+               if (pm)
                {
-                       if ((mh->name == "key") && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex")))
-                               numeric.Add("<key>");
+                       if ((pm->IsParameterSecret()) && (!channel->HasUser(user)) && (!user->HasPrivPermission("channels/auspex")))
+                               numeric.Add("<" + mh->name + ">");
                        else
                                numeric.Add(channel->GetModeParameter(mh));
                }
        }
        numeric.Flush();
-       user->WriteNumeric(960, channel->name, "End of mode list");
+       user->WriteNumeric(RPL_ENDOFPROPLIST, channel->name, "End of mode list");
 }
 
 class CommandProp : public SplitCommand
@@ -49,15 +62,15 @@ class CommandProp : public SplitCommand
        CommandProp(Module* parent)
                : SplitCommand(parent, "PROP", 1)
        {
-               syntax = "<user|channel> {[+-]<mode> [<value>]}*";
+               syntax = "<channel> [[(+|-)]<mode> [<value>]]";
        }
 
-       CmdResult HandleLocal(const std::vector<std::string>& parameters, LocalUser* src) CXX11_OVERRIDE
+       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;
                }
 
@@ -105,8 +118,9 @@ class DummyZ : public ModeHandler
        // Handle /MODE #chan Z
        void DisplayList(User* user, Channel* chan) CXX11_OVERRIDE
        {
-               if (IS_LOCAL(user))
-                       ::DisplayList(static_cast<LocalUser*>(user), chan);
+               LocalUser* luser = IS_LOCAL(user);
+               if (luser)
+                       ::DisplayList(luser, chan);
        }
 };
 
@@ -121,7 +135,7 @@ 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() CXX11_OVERRIDE