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 * ---------------------------------------------------
17 /** Handle /NICK. These command handlers can be reloaded by the core,
18 * and handle basic RFC1459 commands. Commands within modules work
19 * the same way, however, they can be fully unloaded, where these
22 class CommandNick : public Command
25 /** Constructor for nick.
27 CommandNick ( Module* parent) : Command(parent,"NICK", 1, 1) { works_before_reg = true; syntax = "<newnick>"; Penalty = 0; }
29 * @param parameters The parameters to the comamnd
30 * @param pcnt The number of parameters passed to teh command
31 * @param user The user issuing the command
32 * @return A value from CmdResult to indicate command success or failure.
34 CmdResult Handle(const std::vector<std::string>& parameters, User *user);
37 /** Handle nick changes from users.
38 * NOTE: If you are used to ircds based on ircd2.8, and are looking
39 * for the client introduction code in here, youre in the wrong place.
40 * You need to look in the spanningtree module for this!
42 CmdResult CommandNick::Handle (const std::vector<std::string>& parameters, User *user)
44 std::string oldnick = user->nick;
45 std::string newnick = parameters[0];
47 // anything except the initial NICK gets a flood penalty
48 if (user->registered == REG_ALL && IS_LOCAL(user))
49 IS_LOCAL(user)->CommandFloodPenalty += 4000;
53 user->WriteNumeric(432, "%s * :Erroneous Nickname", oldnick.c_str());
61 else if (!ServerInstance->IsNick(newnick.c_str(), ServerInstance->Config->Limits.NickMax))
63 user->WriteNumeric(432, "%s %s :Erroneous Nickname", user->nick.c_str(),newnick.c_str());
67 if (!user->ChangeNick(newnick, false))
70 if (user->registered < REG_NICKUSER)
72 user->registered = (user->registered | REG_NICK);
73 if (user->registered == REG_NICKUSER)
75 /* user is registered now, bit 0 = USER command, bit 1 = sent a NICK command */
77 FIRST_MOD_RESULT(OnUserRegister, MOD_RESULT, (IS_LOCAL(user)));
78 if (MOD_RESULT == MOD_RES_DENY)
81 // return early to not penalize new users
90 COMMAND_INIT(CommandNick)