X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sajoin.cpp;h=2471efe91fae41e54c8c34d24b138217a87c5d7f;hb=9dd72b7003963d868a23da930a91300b49ab4959;hp=deea7abd426de51ab7d2b5b531c2c7d7d76188f6;hpb=268e6a408792045abf729214f40abd250250f3f0;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sajoin.cpp b/src/modules/m_sajoin.cpp index deea7abd4..2471efe91 100644 --- a/src/modules/m_sajoin.cpp +++ b/src/modules/m_sajoin.cpp @@ -1,53 +1,77 @@ -// Sajoin 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 SAJOIN command */ -Server *Srv; - -void handle_sajoin(char **parameters, int pcnt, userrec *user) +static Server *Srv; + +class cmd_sajoin : public command_t { - userrec* dest = Srv->FindNick(std::string(parameters[0])); - if (dest) + public: + cmd_sajoin() : command_t("SAJOIN", 'o', 2) { + this->source = "m_sajoin.so"; + } - for (int x = 0; x < strlen(parameters[1]); x++) + void Handle (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 (!IsValidChannelName(parameters[1])) + { + /* we didn't need to check this for each character ;) */ + Srv->SendTo(NULL,user,"NOTICE "+std::string(user->nick)+" :*** Invalid characters in channel name"); + return; + } - Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]); - Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick)); + Srv->SendOpers(std::string(user->nick)+" used SAJOIN to make "+std::string(dest->nick)+" join "+parameters[1]); + Srv->JoinUserToChannel(dest,std::string(parameters[1]),std::string(dest->nick)); + } } -} - +}; class ModuleSajoin : public Module { + cmd_sajoin* mycommand; public: - ModuleSajoin() + ModuleSajoin(Server* Me) + : Module::Module(Me) { - Srv = new Server; - Srv->AddCommand("SAJOIN",handle_sajoin,'o',2); + Srv = Me; + mycommand = new cmd_sajoin(); + Srv->AddCommand(mycommand); } virtual ~ModuleSajoin() { - delete Srv; } virtual Version GetVersion() { - return Version(1,0,0,1); + return Version(1,0,0,1,VF_VENDOR); } }; @@ -65,9 +89,9 @@ class ModuleSajoinFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(Server* Me) { - return new ModuleSajoin; + return new ModuleSajoin(Me); } };