X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fcmd_kick.cpp;h=27552f66c8a03f7031603a6061b23dfd1360fc2a;hb=46ff0bed0047c4cd05828c5f46dce63176e5084b;hp=29e0860e05a3b803141b616465783cbdd704592f;hpb=088ec6caed6ff877169fcbd9914b8653374f6829;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/cmd_kick.cpp b/src/cmd_kick.cpp index 29e0860e0..27552f66c 100644 --- a/src/cmd_kick.cpp +++ b/src/cmd_kick.cpp @@ -2,40 +2,42 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. - * E-mail: - * - * + * InspIRCd: (C) 2002-2007 InspIRCd Development Team + * See: http://www.inspircd.org/wiki/index.php/Credits * - * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; see * the file COPYING for details. * * --------------------------------------------------- */ -#include "inspircd_config.h" #include "users.h" -#include "commands.h" -#include "helperfuncs.h" +#include "inspircd.h" #include "commands/cmd_kick.h" -void cmd_kick::Handle (char **parameters, int pcnt, userrec *user) +extern "C" DllExport command_t* init_command(InspIRCd* Instance) +{ + return new cmd_kick(Instance); +} + +/** Handle /KICK + */ +CmdResult cmd_kick::Handle (const char** parameters, int pcnt, userrec *user) { char reason[MAXKICK]; - chanrec* c = FindChan(parameters[0]); - userrec* u = Find(parameters[1]); + chanrec* c = ServerInstance->FindChan(parameters[0]); + userrec* u = ServerInstance->FindNick(parameters[1]); if (!u || !c) { - WriteServ(user->fd, "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]); - return; + user->WriteServ( "401 %s %s :No such nick/channel", user->nick, u ? parameters[0] : parameters[1]); + return CMD_FAILURE; } - if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!is_uline(user->server))) + if ((IS_LOCAL(user)) && (!c->HasUser(user)) && (!ServerInstance->ULine(user->server))) { - WriteServ(user->fd, "442 %s %s :You're not on that channel!", user->nick, parameters[0]); - return; + user->WriteServ( "442 %s %s :You're not on that channel!", user->nick, parameters[0]); + return CMD_FAILURE; } if (pcnt > 2) @@ -47,5 +49,9 @@ void cmd_kick::Handle (char **parameters, int pcnt, userrec *user) strlcpy(reason, user->nick, MAXKICK - 1); } - kick_channel(user, u, c, reason); + if (!c->KickUser(user, u, reason)) + /* Nobody left here, delete the chanrec */ + delete c; + + return CMD_SUCCESS; }