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->ForceNickChange(parameters[1].c_str()))
62 ServerInstance->SNO->WriteToSnoMask('a', oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
63 ServerInstance->PI->SendSNONotice("A", oldnick+" used SANICK to change "+newnick+" to "+parameters[1]);
67 ServerInstance->SNO->WriteToSnoMask('a', oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
68 ServerInstance->PI->SendSNONotice("A", oldnick+" failed SANICK (from "+newnick+" to "+parameters[1]+")");
75 RouteDescriptor GetRouting(User* user, const std::vector<std::string>& parameters)
77 User* dest = ServerInstance->FindNick(parameters[0]);
79 return ROUTE_OPT_UCAST(dest->server);
80 return ROUTE_LOCALONLY;
85 class ModuleSanick : public Module
92 ServerInstance->AddCommand(&cmd);
95 virtual ~ModuleSanick()
99 virtual Version GetVersion()
101 return Version("Provides support for SANICK command", VF_OPTCOMMON | VF_VENDOR);
106 MODULE_INIT(ModuleSanick)