1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2010 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(Module* Creator) : Command(Creator,"SANICK", 2)
25 flags_needed = 'o'; Penalty = 0; syntax = "<nick> <new-nick>";
26 TRANSLATE3(TR_NICK, TR_TEXT, TR_END);
29 CmdResult Handle (const std::vector<std::string>& parameters, User *user)
31 User* target = ServerInstance->FindNick(parameters[0]);
33 /* Do local sanity checks and bails */
36 if (target && ServerInstance->ULine(target->server))
38 user->WriteNumeric(ERR_NOPRIVILEGES, "%s :Cannot use an SA command on a u-lined client",user->nick.c_str());
44 user->WriteServ("NOTICE %s :*** No such nickname: '%s'", user->nick.c_str(), parameters[0].c_str());
48 if (!ServerInstance->IsNick(parameters[1].c_str(), ServerInstance->Config->Limits.NickMax))
50 user->WriteServ("NOTICE %s :*** Invalid nickname '%s'", user->nick.c_str(), parameters[1].c_str());
55 /* Have we hit target's server yet? */
56 if (target && IS_LOCAL(target))
58 std::string oldnick = user->nick;
59 std::string newnick = target->nick;
60 if (target->ChangeNick(parameters[1], true))
62 ServerInstance->SNO->WriteGlobalSno('a', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
66 ServerInstance->SNO->WriteGlobalSno('a', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
73 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
75 User* dest = ServerInstance->FindNick(parameters[0]);
77 return ROUTE_OPT_UCAST(dest->server);
78 return ROUTE_LOCALONLY;
83 class ModuleSanick : public Module
90 ServerInstance->AddCommand(&cmd);
93 virtual ~ModuleSanick()
97 virtual Version GetVersion()
99 return Version("Provides support for SANICK command", VF_OPTCOMMON | VF_VENDOR);
104 MODULE_INIT(ModuleSanick)