X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_saquit.cpp;h=d43b9710238d0ac87ace78dd34096e68277e7269;hb=c4458ecc70025aeac7ca87115ed0a698e7bbcdad;hp=d7151e5ec9cec77718793e4fb1a47f431404b1ef;hpb=632ca0fd6a2cfa3d06f87b77ccffcc2e5a835572;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_saquit.cpp b/src/modules/m_saquit.cpp index d7151e5ec..d43b97102 100644 --- a/src/modules/m_saquit.cpp +++ b/src/modules/m_saquit.cpp @@ -1,3 +1,21 @@ +/* +------------------------------------+ + * | 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; + /* * SAQUIT module for InspIRCd * Author: w00t @@ -16,44 +34,58 @@ /* $ModDesc: Provides support for an SAQUIT command, exits user with a reason */ -Server *Srv; - -void handle_saquit(char **parameters, int pcnt, userrec *user) -{ - userrec* dest = Srv->FindNick(std::string(parameters[0])); - if (dest) - { +static Server *Srv; - std::string line = ""; - for (int i = 1; i < pcnt - 1; i++) +class cmd_saquit : public command_t +{ + public: + cmd_saquit () : command_t("SAQUIT",'o',2) { - line = line + std::string(parameters[i]) + " "; + this->source = "m_saquit.so"; } - line = line + std::string(parameters[pcnt-1]) - Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line); - Srv->QuitUser(dest, line); + void Handle (const char** parameters, int pcnt, userrec *user) + { + userrec* dest = Srv->FindNick(std::string(parameters[0])); + if (dest) + { + if (Srv->IsUlined(dest->server)) + { + WriteServ(user->fd,"990 %s :Cannot use an SA command on a u-lined client",user->nick); + return; + } + std::string line = ""; + for (int i = 1; i < pcnt - 1; i++) + { + line = line + std::string(parameters[i]) + " "; + } + line = line + std::string(parameters[pcnt-1]); + + Srv->SendOpers(std::string(user->nick)+" used SAQUIT to make "+std::string(dest->nick)+" quit with a reason of "+line); + Srv->QuitUser(dest, line); + } } -} - +}; class ModuleSaquit : public Module { + cmd_saquit* mycommand; public: - ModuleSaquit() + ModuleSaquit(Server* Me) + : Module::Module(Me) { - Srv = new Server; - Srv->AddCommand("SAQUIT",handle_saquit,'o',2); + Srv = Me; + mycommand = new cmd_saquit(); + Srv->AddCommand(mycommand); } virtual ~ModuleSaquit() { - delete Srv; } virtual Version GetVersion() { - return Version(1,0,0,0); + return Version(1,0,0,1,VF_VENDOR); } }; @@ -71,9 +103,9 @@ class ModuleSaquitFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(Server* Me) { - return new ModuleSaquit; + return new ModuleSaquit(Me); } };