X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcoremods%2Fcore_list.cpp;h=e4da6ddb71d1644b1108a593fdb066fd3a55e54c;hb=d38595e7e14e7509e744d33df657d50d00cc201f;hp=600ec47c2e3b31772aaa92de9e2cdcf990577fdd;hpb=91e0af0fc4889f20d2f63426f8fe379674fc0393;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/coremods/core_list.cpp b/src/coremods/core_list.cpp index 600ec47c2..e4da6ddb7 100644 --- a/src/coremods/core_list.cpp +++ b/src/coremods/core_list.cpp @@ -1,8 +1,14 @@ /* * InspIRCd -- Internet Relay Chat Daemon * + * Copyright (C) 2017-2020 Sadie Powell + * Copyright (C) 2015 Daniel Vassdal + * Copyright (C) 2013-2016 Attila Molnar + * Copyright (C) 2012 Robby * Copyright (C) 2009 Daniel De Graaf - * Copyright (C) 2007 Robin Burchell + * Copyright (C) 2008 Robin Burchell + * Copyright (C) 2007 Dennis Friis + * Copyright (C) 2006-2007, 2010 Craig Edwards * * 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; } @@ -56,13 +64,13 @@ class CommandList : public Command * @param user The user issuing the command * @return A value from CmdResult to indicate command success or failure. */ - CmdResult Handle(const std::vector& parameters, User* user) CXX11_OVERRIDE; + CmdResult Handle(User* user, const Params& parameters) CXX11_OVERRIDE; }; /** Handle /LIST */ -CmdResult CommandList::Handle (const std::vector& parameters, User *user) +CmdResult CommandList::Handle(User* user, const Params& parameters) { // C: Searching based on creation time, via the "Cval" modifiers // to search for a channel creation time that is lower or higher than val @@ -87,36 +95,37 @@ CmdResult CommandList::Handle (const std::vector& parameters, User 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(parameters[0].c_str() + 1); + maxusers = ConvToNum(constraint.c_str() + 1); } - else if (parameters[0][0] == '>') + else if (constraint[0] == '>') { - minusers = ConvToNum(parameters[0].c_str() + 1); + minusers = ConvToNum(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 (const std::vector& parameters, User // 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& tokens) CXX11_OVERRIDE { tokens["ELIST"] = "CMNTU";