]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_user/cmd_ison.cpp
Add the msgid tag to all outgoing messages.
[user/henk/code/inspircd.git] / src / coremods / core_user / cmd_ison.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
5  *   Copyright (C) 2007 Robin Burchell <robin+git@viroteck.net>
6  *
7  * This file is part of InspIRCd.  InspIRCd is free software: you can
8  * redistribute it and/or modify it under the terms of the GNU General Public
9  * License as published by the Free Software Foundation, version 2.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
14  * details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19
20
21 #include "inspircd.h"
22 #include "core_user.h"
23
24 class IsonReplyBuilder : public Numeric::Builder<' ', true>
25 {
26  public:
27         IsonReplyBuilder(LocalUser* user)
28                 : Numeric::Builder<' ', true>(user, RPL_ISON)
29         {
30         }
31
32         void AddNick(const std::string& nickname)
33         {
34                 User* const user = ServerInstance->FindNickOnly(nickname);
35                 if ((user) && (user->registered == REG_ALL))
36                         Add(user->nick);
37         }
38 };
39
40 /** Handle /ISON
41  */
42 CmdResult CommandIson::HandleLocal(LocalUser* user, const Params& parameters)
43 {
44         IsonReplyBuilder reply(user);
45
46         for (std::vector<std::string>::const_iterator i = parameters.begin(); i != parameters.end()-1; ++i)
47         {
48                 const std::string& targetstr = *i;
49                 reply.AddNick(targetstr);
50         }
51
52         // Last parameter can be a space separated list
53         irc::spacesepstream ss(parameters.back());
54         for (std::string token; ss.GetToken(token); )
55                 reply.AddNick(token);
56
57         reply.Flush();
58         return CMD_SUCCESS;
59 }