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