]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_kick.cpp
Fix for parameters which contain a colon (which is not the first char in the string)
[user/henk/code/inspircd.git] / src / cmd_kick.cpp
1 /*       +------------------------------------+
2  *       | Inspire Internet Relay Chat Daemon |
3  *       +------------------------------------+
4  *
5  *  InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
6  *                       E-mail:
7  *                <brain@chatspike.net>
8  *                <Craig@chatspike.net>
9  *
10  * Written by Craig Edwards, Craig McLure, and others.
11  * This program is free but copyrighted software; see
12  *            the file COPYING for details.
13  *
14  * ---------------------------------------------------
15  */
16
17 #include "users.h"
18 #include "inspircd.h"
19 #include "commands/cmd_kick.h"
20
21 void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user)
22 {
23         char reason[MAXKICK];
24         chanrec* c = ServerInstance->FindChan(parameters[0]);
25         userrec* u = ServerInstance->FindNick(parameters[1]);
26
27         if (!u || !c)
28         {
29                 user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]);
30                 return;
31         }
32
33         if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server)))
34         {
35                 user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0]);
36                 return;
37         }
38
39         if (pcnt > 2)
40         {
41                 strlcpy(reason, parameters[2], MAXKICK - 1);
42         }
43         else
44         {
45                 strlcpy(reason, user->nick, MAXKICK - 1);
46         }
47
48         if (!c->KickUser(user, u, reason))
49                 /* Nobody left here, delete the chanrec */
50                 delete c;
51 }