X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sanick.cpp;h=818672ce4897485b0934dbf64c3ec668dcb54c9c;hb=d54fd9b1e6b31f69332a9241b5f17330c0ad61e0;hp=65de142505beeffeb0b7f8ed4f900b36fd8eb8af;hpb=211b24ba8cf6e21f435f145b0366adc8a3b62460;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index 65de14250..818672ce4 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -2,61 +2,87 @@ * | 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. * * --------------------------------------------------- */ +using namespace std; + #include #include #include "users.h" #include "channels.h" #include "modules.h" +#include "inspircd.h" /* $ModDesc: Provides support for SANICK command */ -Server *Srv; - -void handle_sanick(char **parameters, int pcnt, userrec *user) + + + +class cmd_sanick : public command_t { - userrec* source = Srv->FindNick(std::string(parameters[0])); - if (source) + public: + cmd_sanick (InspIRCd* Instance) : command_t(Instance,"SANICK", 'o', 2) { - if (Srv->IsNick(std::string(parameters[1]))) + this->source = "m_sanick.so"; + syntax = " "; + } + + void Handle (const char** parameters, int pcnt, userrec *user) + { + userrec* source = ServerInstance->FindNick(parameters[0]); + if (source) { - // FIX by brain: Cant use source->nick here because if it traverses a server link then - // source->nick becomes invalid as the object data moves in memory. - Srv->SendOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]); - Srv->ChangeUserNick(source,std::string(parameters[1])); + if (ServerInstance->ULine(source->server)) + { + user->WriteServ("990 %s :Cannot use an SA command on a u-lined client",user->nick); + return; + } + if (ServerInstance->IsNick(parameters[1])) + { + // FIX by brain: Cant use source->nick here because if it traverses a server link then + // source->nick becomes invalid as the object data moves in memory. + ServerInstance->WriteOpers(std::string(user->nick)+" used SANICK to change "+std::string(parameters[0])+" to "+parameters[1]); + if (!source->ForceNickChange(parameters[1])) + { + /* We couldnt change the nick */ + userrec::QuitUser(ServerInstance, source, "Nickname collision"); + return; + } + } } } -} +}; class ModuleSanick : public Module { + cmd_sanick* mycommand; public: - ModuleSanick() + ModuleSanick(InspIRCd* Me) + : Module::Module(Me) { - Srv = new Server; - Srv->AddCommand("SANICK",handle_sanick,'o',2,"m_sanick.so"); + + mycommand = new cmd_sanick(ServerInstance); + ServerInstance->AddCommand(mycommand); } virtual ~ModuleSanick() { - delete Srv; } virtual Version GetVersion() { - return Version(1,0,0,1); + return Version(1,0,0,1,VF_VENDOR); } }; @@ -74,9 +100,9 @@ class ModuleSanickFactory : public ModuleFactory { } - virtual Module * CreateModule() + virtual Module * CreateModule(InspIRCd* Me) { - return new ModuleSanick; + return new ModuleSanick(Me); } };