]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/coremods/core_user/cmd_part.cpp
Sync helpop chmodes s and p with docs
[user/henk/code/inspircd.git] / src / coremods / core_user / cmd_part.cpp
1 /*
2  * InspIRCd -- Internet Relay Chat Daemon
3  *
4  *   Copyright (C) 2018 Sadie Powell <sadie@witchery.services>
5  *   Copyright (C) 2017 B00mX0r <b00mx0r@aureus.pw>
6  *   Copyright (C) 2012-2016 Attila Molnar <attilamolnar@hush.com>
7  *   Copyright (C) 2012, 2019 Robby <robby@chatbelgie.be>
8  *   Copyright (C) 2009 Uli Schlachter <psychon@inspircd.org>
9  *   Copyright (C) 2009 Daniel De Graaf <danieldg@inspircd.org>
10  *   Copyright (C) 2007-2008 Robin Burchell <robin+git@viroteck.net>
11  *   Copyright (C) 2007 Dennis Friis <peavey@inspircd.org>
12  *   Copyright (C) 2006, 2010 Craig Edwards <brain@inspircd.org>
13  *
14  * This file is part of InspIRCd.  InspIRCd is free software: you can
15  * redistribute it and/or modify it under the terms of the GNU General Public
16  * License as published by the Free Software Foundation, version 2.
17  *
18  * This program is distributed in the hope that it will be useful, but WITHOUT
19  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
21  * details.
22  *
23  * You should have received a copy of the GNU General Public License
24  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
25  */
26
27
28 #include "inspircd.h"
29 #include "core_user.h"
30
31 CommandPart::CommandPart(Module* parent)
32         : Command(parent, "PART", 1, 2)
33 {
34         Penalty = 5;
35         syntax = "<channel>[,<channel>]+ [:<reason>]";
36 }
37
38 CmdResult CommandPart::Handle(User* user, const Params& parameters)
39 {
40         std::string reason;
41         if (parameters.size() > 1)
42         {
43                 if (IS_LOCAL(user))
44                         msgwrap.Wrap(parameters[1], reason);
45                 else
46                         reason = parameters[1];
47         }
48
49         if (CommandParser::LoopCall(user, this, parameters, 0))
50                 return CMD_SUCCESS;
51
52         Channel* c = ServerInstance->FindChan(parameters[0]);
53
54         if (!c)
55         {
56                 user->WriteNumeric(Numerics::NoSuchChannel(parameters[0]));
57                 return CMD_FAILURE;
58         }
59
60         if (!c->PartUser(user, reason))
61         {
62                 user->WriteNumeric(ERR_NOTONCHANNEL, c->name, "You're not on that channel");
63                 return CMD_FAILURE;
64         }
65
66         return CMD_SUCCESS;
67 }
68
69 RouteDescriptor CommandPart::GetRouting(User* user, const Params& parameters)
70 {
71         return (IS_LOCAL(user) ? ROUTE_LOCALONLY : ROUTE_BROADCAST);
72 }