]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/coremods/core_channel/cmd_names.cpp
Release v3.8.0.
[user/henk/code/inspircd.git] / src / coremods / core_channel / cmd_names.cpp
index 53934b5e3a06bf36d5a5416b124b4410560acf02..bf13fac65a82a7fdaa32464fd014da4230259e57 100644 (file)
@@ -1,8 +1,16 @@
 /*
  * InspIRCd -- Internet Relay Chat Daemon
  *
+ *   Copyright (C) 2018-2019 Sadie Powell <sadie@witchery.services>
+ *   Copyright (C) 2018 Dylan Frank <b00mx0r@aureus.pw>
+ *   Copyright (C) 2017 B00mX0r <b00mx0r@aureus.pw>
+ *   Copyright (C) 2013-2016 Attila Molnar <attilamolnar@hush.com>
+ *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
+ *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
+ *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
+ *   Copyright (C) 2006, 2008, 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
 
 #include "inspircd.h"
 #include "core_channel.h"
+#include "modules/names.h"
 
 CommandNames::CommandNames(Module* parent)
        : SplitCommand(parent, "NAMES", 0, 0)
        , secretmode(parent, "secret")
        , privatemode(parent, "private")
        , invisiblemode(parent, "invisible")
+       , namesevprov(parent, "event/names")
 {
-       syntax = "{<channel>{,<channel>}}";
+       syntax = "[<channel>[,<channel>]+]";
 }
 
 /** Handle /NAMES
  */
-CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters, LocalUser* user)
+CmdResult CommandNames::HandleLocal(LocalUser* user, const Params& parameters)
 {
        Channel* c;
 
-       if (!parameters.size())
+       if (parameters.empty())
        {
                user->WriteNumeric(RPL_ENDOFNAMES, '*', "End of /NAMES list.");
                return CMD_SUCCESS;
@@ -62,13 +72,13 @@ CmdResult CommandNames::HandleLocal(const std::vector<std::string>& parameters,
                }
        }
 
-       user->WriteNumeric(Numerics::NoSuchNick(parameters[0]));
+       user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
        return CMD_FAILURE;
 }
 
 void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible)
 {
-       Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false, chan->name.size() + 4);
+       Numeric::Builder<' '> reply(user, RPL_NAMREPLY, false, chan->name.size() + 3);
        Numeric::Numeric& numeric = reply.GetNumeric();
        if (chan->IsModeSet(secretmode))
                numeric.push(std::string(1, '@'));
@@ -100,13 +110,9 @@ void CommandNames::SendNames(LocalUser* user, Channel* chan, bool show_invisible
                nick = i->first->nick;
 
                ModResult res;
-               FIRST_MOD_RESULT(OnNamesListItem, res, (user, memb, prefixlist, nick));
-
-               // See if a module wants us to exclude this user from NAMES
-               if (res == MOD_RES_DENY)
-                       continue;
-
-               reply.Add(prefixlist, nick);
+               FIRST_MOD_RESULT_CUSTOM(namesevprov, Names::EventListener, OnNamesListItem, res, (user, memb, prefixlist, nick));
+               if (res != MOD_RES_DENY)
+                       reply.Add(prefixlist, nick);
        }
 
        reply.Flush();