]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/commands/cmd_part.cpp
Nuke trailing spaces
[user/henk/code/inspircd.git] / src / commands / cmd_part.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd: (C) 2002-2009 InspIRCd Development Team
6  * See: http://www.inspircd.org/wiki/index.php/Credits
7  *
8  * This program is free but copyrighted software; see
9  *            the file COPYING for details.
10  *
11  * ---------------------------------------------------
12  */
13
14 #include "inspircd.h"
15 #include "commands/cmd_part.h"
16
17 extern "C" DllExport Command* init_command(InspIRCd* Instance)
18 {
19         return new CommandPart(Instance);
20 }
21
22 CmdResult CommandPart::Handle (const std::vector<std::string>& parameters, User *user)
23 {
24         std::string reason;
25
26         if (IS_LOCAL(user))
27         {
28                 if (*ServerInstance->Config->FixedPart)
29                         reason = ServerInstance->Config->FixedPart;
30                 else
31                 {
32                         if (parameters.size() > 1)
33                                 reason = ServerInstance->Config->PrefixPart + std::string(parameters[1]) + ServerInstance->Config->SuffixPart;
34                         else
35                                 reason = "";
36                 }
37         }
38         else
39         {
40                 reason = parameters.size() > 1 ? parameters[1] : "";
41         }
42
43         if (ServerInstance->Parser->LoopCall(user, this, parameters, 0))
44                 return CMD_SUCCESS;
45
46         Channel* c = ServerInstance->FindChan(parameters[0]);
47
48         if (c)
49         {
50                 if (!c->PartUser(user, reason))
51                         /* Arse, who stole our channel! :/ */
52                         delete c;
53         }
54         else
55         {
56                 user->WriteServ( "401 %s %s :No such channel", user->nick.c_str(), parameters[0].c_str());
57                 return CMD_FAILURE;
58         }
59
60         return CMD_SUCCESS;
61 }