X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_sanick.cpp;h=180e4ba810c043b29bbf15586731993e8130aa9d;hb=8085aa879bd989b526791797910295944a364084;hp=d681fb01a6fc04ac840d32088b0caddf881ae2da;hpb=43847ec9c7e1a195163eb4c529f1c92fd1ace0a4;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_sanick.cpp b/src/modules/m_sanick.cpp index d681fb01a..180e4ba81 100644 --- a/src/modules/m_sanick.cpp +++ b/src/modules/m_sanick.cpp @@ -3,7 +3,7 @@ * +------------------------------------+ * * InspIRCd: (C) 2002-2009 InspIRCd Development Team - * See: http://www.inspircd.org/wiki/index.php/Credits + * See: http://wiki.inspircd.org/Credits * * This program is free but copyrighted software; see * the file COPYING for details. @@ -30,56 +30,62 @@ class CommandSanick : public Command CmdResult Handle (const std::vector& parameters, User *user) { User* target = ServerInstance->FindNick(parameters[0]); - if (target) + + /* Do local sanity checks and bails */ + if (IS_LOCAL(user)) { - if (ServerInstance->ULine(target->server)) + if (target && ServerInstance->ULine(target->server)) { user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str()); return CMD_FAILURE; } - std::string oldnick = user->nick; - if (IS_LOCAL(user) && !ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) + + if (!target) { - user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); + user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str()); + return CMD_FAILURE; } - else + + if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax)) { - if (target->ForceNickChange(parameters[1].c_str())) - { - ServerInstance->SNO->WriteToSnoMask('A', oldnick+" used SANICK to change "+parameters[0]+" to "+parameters[1]); - return CMD_SUCCESS; - } - else - { - /* We couldnt change the nick */ - ServerInstance->SNO->WriteToSnoMask('A', oldnick+" failed SANICK (from "+parameters[0]+" to "+parameters[1]+")"); - return CMD_FAILURE; - } + user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str()); + return CMD_FAILURE; } - - return CMD_FAILURE; } - else + + /* Have we hit target's server yet? */ + if (target && IS_LOCAL(target)) { - user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str()); + std::string oldnick = user->nick; + std::string newnick = target->nick; + if (target->ForceNickChange(parameters[1].c_str())) + { + ServerInstance->SNO->WriteToSnoMask('a', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]); + ServerInstance->PI->SendSNONotice("A", oldnick+" used SANICK to change "+newnick+" to "+parameters[1]); + } + else + { + ServerInstance->SNO->WriteToSnoMask('a', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")"); + ServerInstance->PI->SendSNONotice("A", oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")"); + } + /* Yes, hit target and we have sent our NICK out, we can now bail */ + return CMD_LOCALONLY; } - return CMD_FAILURE; + /* No, route it on */ + return CMD_SUCCESS; } }; class ModuleSanick : public Module { - CommandSanick* mycommand; + CommandSanick cmd; public: ModuleSanick(InspIRCd* Me) - : Module(Me) + : Module(Me), cmd(Me) { - - mycommand = new CommandSanick(ServerInstance); - ServerInstance->AddCommand(mycommand); - + ServerInstance->AddCommand(&cmd); } virtual ~ModuleSanick()