]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_channel/cmd_join.cpp
Convert WriteNumeric() calls to pass the parameters of the numeric as method parameters
[user/henk/code/inspircd.git] / src / coremods / core_channel / cmd_join.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_channel.h"
23
24 CommandJoin::CommandJoin(Module* parent)
25         : SplitCommand(parent, "JOIN", 1, 2)
26 {
27         syntax = "<channel>{,<channel>} {<key>{,<key>}}";
28         Penalty = 2;
29 }
30
31 /** Handle /JOIN
32  */
33 CmdResult CommandJoin::HandleLocal(const std::vector<std::string>& parameters, LocalUser *user)
34 {
35         if (parameters.size() > 1)
36         {
37                 if (CommandParser::LoopCall(user, this, parameters, 0, 1, false))
38                         return CMD_SUCCESS;
39
40                 if (ServerInstance->IsChannel(parameters[0]))
41                 {
42                         Channel::JoinUser(user, parameters[0], false, parameters[1]);
43                         return CMD_SUCCESS;
44                 }
45         }
46         else
47         {
48                 if (CommandParser::LoopCall(user, this, parameters, 0, -1, false))
49                         return CMD_SUCCESS;
50
51                 if (ServerInstance->IsChannel(parameters[0]))
52                 {
53                         Channel::JoinUser(user, parameters[0]);
54                         return CMD_SUCCESS;
55                 }
56         }
57
58         user->WriteNumeric(ERR_NOSUCHCHANNEL, parameters[0], "Invalid channel name");
59         return CMD_FAILURE;
60 }