]> git.netwichtig.de Git - user/henk/code/inspircd.git/blob - src/cmd_kick.cpp
042c6c02d0a5441f4b32ec7ca18b2fce5b6bbc0a
[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 "inspircd_config.h"
18 #include "users.h"
19 #include "commands.h"
20 #include "helperfuncs.h"
21 #include "commands/cmd_kick.h"
22
23 void cmd_kick::Handle (const char** parameters, int pcnt, userrec *user)
24 {
25         char reason[MAXKICK];
26         chanrec* c = FindChan(parameters[0]);
27         userrec* u = Find(parameters[1]);
28
29         if (!u || !c)
30         {
31                 user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]);
32                 return;
33         }
34
35         if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!is_uline(user->server)))
36         {
37                 user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0]);
38                 return;
39         }
40
41         if (pcnt > 2)
42         {
43                 strlcpy(reason, parameters[2], MAXKICK - 1);
44         }
45         else
46         {
47                 strlcpy(reason, user->nick, MAXKICK - 1);
48         }
49
50         if (!c->KickUser(user, u, reason))
51                 /* Nobody left here, delete the chanrec */
52                 delete c;
53 }