X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sapart.cpp;h=590c22c675b38a45bee247ae496539fbc880f143;hb=66098d307c036997e51eaea21724615e27fdc3e9;hp=21e2f7fbec7709bf910fca9ba60c2c67d41c102b;hpb=2d821f2980825be73e3f90b47ffff365b0ec5ecb;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp index 21e2f7fbe..590c22c67 100644 --- a/src/modules/m_sapart.cpp +++ b/src/modules/m_sapart.cpp @@ -2,14 +2,14 @@ * | Inspire Internet Relay Chat Daemon | * +------------------------------------+ * - * Inspire is copyright (C) 2002-2004 ChatSpike-Dev. - * E-mail: - * - * + * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev. + * E-mail: + * + * * * Written by Craig Edwards, Craig McLure, and others. * This program is free but copyrighted software; see - * the file COPYING for details. + * the file COPYING for details. * * --------------------------------------------------- */ @@ -21,39 +21,52 @@ using namespace std; #include "users.h" #include "channels.h" #include "modules.h" +#include "helperfuncs.h" +#include "inspircd.h" /* $ModDesc: Provides support for unreal-style SAPART command */ -Server *Srv; - -void handle_sapart(char **parameters, int pcnt, userrec *user) + +extern InspIRCd* ServerInstance; + +class cmd_sapart : public command_t { - userrec* dest = Srv->FindNick(std::string(parameters[0])); - if (dest) + public: + cmd_sapart (InspIRCd* Instance) : command_t(Instance,"SAPART", 'o', 2) + { + this->source = "m_sapart.so"; + syntax = " "; + } + + void Handle (const char** parameters, int pcnt, userrec *user) { - for (unsigned int x = 0; x < strlen(parameters[1]); x++) + userrec* dest = ServerInstance->FindNick(parameters[0]); + chanrec* channel = ServerInstance->FindChan(parameters[1]); + if (dest && channel) { - if ((parameters[1][0] != '#') || (parameters[1][x] == ' ') || (parameters[1][x] == ',')) - { - Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); - return; - } + if (ServerInstance->IsUlined(dest->server)) + { + user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick); + return; + } + ServerInstance->WriteOpers(std::string(user->nick)+" used SAPART to make "+dest->nick+" part "+parameters[1]); + if (!channel->PartUser(dest, dest->nick)) + delete channel; } - - Srv->SendOpers(std::string(user->nick)+" used SAPART to make "+std::string(dest->nick)+" part "+parameters[1]); - Srv->PartUserFromChannel(dest,std::string(parameters[1]),std::string(dest->nick)); } -} +}; class ModuleSapart : public Module { + cmd_sapart* mycommand; public: - ModuleSapart(Server* Me) + ModuleSapart(InspIRCd* Me) : Module::Module(Me) { - Srv = Me; - Srv->AddCommand("SAPART",handle_sapart,'o',2,"m_sapart.so"); + + mycommand = new cmd_sapart(ServerInstance); + ServerInstance->AddCommand(mycommand); } virtual ~ModuleSapart() @@ -80,7 +93,7 @@ class ModuleSapartFactory : public ModuleFactory { } - virtual Module * CreateModule(Server* Me) + virtual Module * CreateModule(InspIRCd* Me) { return new ModuleSapart(Me); }