]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_list.cpp
Be more specific when a HTTP parser error happens.
[user/henk/code/inspircd.git] / src / coremods / core_list.cpp
index f03fbbe5e811aae441c2efb899cacd511de1b858..e4da6ddb71d1644b1108a593fdb066fd3a55e54c 100644 (file)
@@ -1,8 +1,14 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2017-2020 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2015 Daniel Vassdal <shutter@canternet.org>
+ *   Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012 Robby <robby@chatbelgie.be>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
- *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2008 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006-2007, 2010 Craig Edwards <brain@inspircd.org>
  *
  * This file is part of InspIRCd.  InspIRCd is free software: you can
  * redistribute it and/or modify it under the terms of the GNU General Public
@@ -41,13 +47,15 @@ class CommandList : public Command
        }
 
  public:
-       /** Constructor for list.
-        */
+       // Whether to show modes in the LIST response.
+       bool showmodes;
+
        CommandList(Module* parent)
                : Command(parent,"LIST", 0, 0)
                , secretmode(creator, "secret")
                , privatemode(creator, "private")
        {
+               allow_empty_last_param = false;
                Penalty = 5;
        }
 
@@ -87,36 +95,37 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
        size_t minusers = 0;
        size_t maxusers = 0;
 
-       if ((parameters.size() == 1) && (!parameters[0].empty()))
+       for (Params::const_iterator iter = parameters.begin(); iter != parameters.end(); ++iter)
        {
-               if (parameters[0][0] == '<')
+               const std::string& constraint = *iter;
+               if (constraint[0] == '<')
                {
-                       maxusers = ConvToNum<size_t>(parameters[0].c_str() + 1);
+                       maxusers = ConvToNum<size_t>(constraint.c_str() + 1);
                }
-               else if (parameters[0][0] == '>')
+               else if (constraint[0] == '>')
                {
-                       minusers = ConvToNum<size_t>(parameters[0].c_str() + 1);
+                       minusers = ConvToNum<size_t>(constraint.c_str() + 1);
                }
-               else if (!parameters[0].compare(0, 2, "C<", 2))
+               else if (!constraint.compare(0, 2, "C<", 2) || !constraint.compare(0, 2, "c<", 2))
                {
-                       mincreationtime = ParseMinutes(parameters[0]);
+                       mincreationtime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "C>", 2))
+               else if (!constraint.compare(0, 2, "C>", 2) || !constraint.compare(0, 2, "c>", 2))
                {
-                       maxcreationtime = ParseMinutes(parameters[0]);
+                       maxcreationtime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "T<", 2))
+               else if (!constraint.compare(0, 2, "T<", 2) || !constraint.compare(0, 2, "t<", 2))
                {
-                       mintopictime = ParseMinutes(parameters[0]);
+                       mintopictime = ParseMinutes(constraint);
                }
-               else if (!parameters[0].compare(0, 2, "T>", 2))
+               else if (!constraint.compare(0, 2, "T>", 2) || !constraint.compare(0, 2, "t>", 2))
                {
-                       maxtopictime = ParseMinutes(parameters[0]);
+                       maxtopictime = ParseMinutes(constraint);
                }
                else
                {
                        // If the glob is prefixed with ! it is inverted.
-                       match = parameters[0].c_str();
+                       match = constraint.c_str();
                        if (match[0] == '!')
                        {
                                match_inverted = true;
@@ -177,11 +186,16 @@ CmdResult CommandList::Handle(User* user, const Params& parameters)
                                // Channel is private (+p) and user is outside/not privileged
                                user->WriteNumeric(RPL_LIST, '*', users, "");
                        }
-                       else
+                       else if (showmodes)
                        {
-                               /* User is in the channel/privileged, channel is not +s */
+                               // Show the list response with the modes and topic.
                                user->WriteNumeric(RPL_LIST, chan->name, users, InspIRCd::Format("[+%s] %s", chan->ChanModes(n), chan->topic.c_str()));
                        }
+                       else
+                       {
+                               // Show the list response with just the modes.
+                               user->WriteNumeric(RPL_LIST, chan->name, users, chan->topic);
+                       }
                }
        }
        user->WriteNumeric(RPL_LISTEND, "End of channel list.");
@@ -200,6 +214,12 @@ class CoreModList : public Module
        {
        }
 
+       void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE
+       {
+               ConfigTag* tag = ServerInstance->Config->ConfValue("options");
+               cmd.showmodes = tag->getBool("modesinlist", true);
+       }
+
        void On005Numeric(std::map<std::string, std::string>& tokens) CXX11_OVERRIDE
        {
                tokens["ELIST"] = "CMNTU";