X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sapart.cpp;h=afbdbdc870d0fd0ab089f759f524bd843deb215b;hb=3a7023f2c595d14778b3f1f7e53d3914698dd500;hp=177a77d9b1d1678215eabc98d449973bb4dee7f3;hpb=268e6a408792045abf729214f40abd250250f3f0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sapart.cpp b/src/modules/m_sapart.cpp index 177a77d9b..afbdbdc87 100644 --- a/src/modules/m_sapart.cpp +++ b/src/modules/m_sapart.cpp @@ -1,52 +1,82 @@ -// Sapart and +g support module by C.J.Edwards +/* +------------------------------------+ + * | Inspire Internet Relay Chat Daemon | + * +------------------------------------+ + * + * 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. + * + * --------------------------------------------------- + */ + +using namespace std; #include #include #include "users.h" #include "channels.h" #include "modules.h" +#include "helperfuncs.h" /* $ModDesc: Provides support for unreal-style SAPART command */ -Server *Srv; - -void handle_sapart(char **parameters, int pcnt, userrec *user) +static Server *Srv; + +class cmd_sapart : public command_t { - userrec* dest = Srv->FindNick(std::string(parameters[0])); - if (dest) + public: + cmd_sapart () : command_t("SAPART", 'o', 2) { - for (int x = 0; x < strlen(parameters[1]); x++) + this->source = "m_sapart.so"; + } + + void Handle (const char** parameters, int pcnt, userrec *user) + { + userrec* dest = Srv->FindNick(std::string(parameters[0])); + if (dest) { - 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 (Srv->IsUlined(dest->server)) + { + WriteServ(user->fd,"990 %s :Cannot use an SA command on a u-lined client",user->nick); + return; + } + if (!IsValidChannelName(parameters[1])) + { + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); + return; + } - 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)); + 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() + ModuleSapart(Server* Me) + : Module::Module(Me) { - Srv = new Server; - Srv->AddCommand("SAPART",handle_sapart,'o',2); + Srv = Me; + mycommand = new cmd_sapart(); + Srv->AddCommand(mycommand); } virtual ~ModuleSapart() { - delete Srv; } virtual Version GetVersion() { - return Version(1,0,0,1); + return Version(1,0,0,1,VF_VENDOR); } }; @@ -64,9 +94,9 @@ class ModuleSapartFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(Server* Me) { - return new ModuleSapart; + return new ModuleSapart(Me); } };