1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2009 InspIRCd Development Team
6 * See: http://wiki.inspircd.org/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
16 /* $ModDesc: Provides support for SANICK command */
20 class CommandSanick : public Command
23 CommandSanick (InspIRCd* Instance) : Command(Instance,"SANICK", "o", 2, false, 0)
25 this->source = "m_sanick.so";
26 syntax = "<nick> <new-nick>";
27 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
30 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
32 User* target = ServerInstance->FindNick(parameters[0]);
34 /* Do local sanity checks and bails */
37 if (target && ServerInstance->ULine(target->server))
39 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
45 user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str());
49 if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
51 user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str());
56 /* Have we hit target's server yet? */
57 if (target && IS_LOCAL(target))
59 std::string oldnick = user->nick;
60 std::string newnick = target->nick;
61 if (target->ForceNickChange(parameters[1].c_str()))
63 ServerInstance->SNO->WriteToSnoMask('A', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
64 ServerInstance->PI->SendSNONotice("A", oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
68 ServerInstance->SNO->WriteToSnoMask('A', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
69 ServerInstance->PI->SendSNONotice("A", oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
71 /* Yes, hit target and we have sent our NICK out, we can now bail */
81 class ModuleSanick : public Module
83 CommandSanick* mycommand;
85 ModuleSanick(InspIRCd* Me)
89 mycommand = new CommandSanick(ServerInstance);
90 ServerInstance->AddCommand(mycommand);
94 virtual ~ModuleSanick()
98 virtual Version GetVersion()
100 return Version("$Id$", VF_COMMON | VF_VENDOR, API_VERSION);
105 MODULE_INIT(ModuleSanick)