Add a call to the NICK handler that allows toggling of allowing invalid nicks to on or off.

Use it in ForceNickChange to allow forced nickchange of a nick to a uid.


git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@7869 e03df62e-2008-0410-955e-edbf42e46eb7
This commit is contained in:
brain 2007-08-27 10:57:25 +00:00
parent c24fcf728d
commit d2be3310ba
3 changed files with 19 additions and 3 deletions

View File

@ -26,6 +26,7 @@
*/ */
class cmd_nick : public command_t class cmd_nick : public command_t
{ {
bool allowinvalid;
public: public:
/** Constructor for nick. /** Constructor for nick.
*/ */
@ -37,6 +38,8 @@ class cmd_nick : public command_t
* @return A value from CmdResult to indicate command success or failure. * @return A value from CmdResult to indicate command success or failure.
*/ */
CmdResult Handle(const char** parameters, int pcnt, userrec *user); CmdResult Handle(const char** parameters, int pcnt, userrec *user);
CmdResult HandleInternal(const unsigned int id, const std::deque<classbase*> &parameters);
}; };
#endif #endif

View File

@ -77,7 +77,7 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
* here first, no TS checks need to take place here) * here first, no TS checks need to take place here)
*/ */
userrec* InUse = ServerInstance->FindNick(parameters[0]); userrec* InUse = ServerInstance->FindNick(parameters[0]);
if (InUse && (InUse != user) && (ServerInstance->IsNick(parameters[0]))) if (InUse && (InUse != user) && ((ServerInstance->IsNick(parameters[0]) || allowinvalid)))
{ {
if (InUse->registered != REG_ALL) if (InUse->registered != REG_ALL)
{ {
@ -98,7 +98,7 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
} }
} }
} }
if ((!ServerInstance->IsNick(parameters[0])) && (IS_LOCAL(user))) if (((!allowinvalid || !ServerInstance->IsNick(parameters[0]))) && (IS_LOCAL(user)))
{ {
user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]); user->WriteServ("432 %s %s :Erroneous Nickname",user->nick,parameters[0]);
return CMD_FAILURE; return CMD_FAILURE;
@ -180,3 +180,8 @@ CmdResult cmd_nick::Handle (const char** parameters, int pcnt, userrec *user)
} }
CmdResult cmd_nick::HandleInternal(const unsigned int id, const std::deque<classbase*> &parameters)
{
allowinvalid = (id != 0);
}

View File

@ -1197,7 +1197,15 @@ bool userrec::ForceNickChange(const char* newnick)
if (this->registered == REG_ALL) if (this->registered == REG_ALL)
{ {
return (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS); std::deque<classbase*> dummy;
command_t* nickhandler = ServerInstance->Parser->GetHandler("NICK");
if (nickhandler)
{
nickhandler->HandleInternal(1, dummy);
bool result = (ServerInstance->Parser->CallHandler("NICK", &newnick, 1, this) == CMD_SUCCESS);
nickhandler->HandleInternal(0, dummy);
return result;
}
} }
return false; return false;
} }