summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/users.h12
-rw-r--r--src/modules/m_chgident.cpp3
-rw-r--r--src/users.cpp23
3 files changed, 36 insertions, 2 deletions
diff --git a/include/users.h b/include/users.h
index 3b1c2a3ec..83ea9bf3f 100644
--- a/include/users.h
+++ b/include/users.h
@@ -685,12 +685,22 @@ class userrec : public connection
/** Change the displayed host of a user.
* ALWAYS use this function, rather than writing userrec::dhost directly,
* as this triggers module events allowing the change to be syncronized to
- * remote servers.
+ * remote servers. This will also emulate a QUIT and rejoin (where configured)
+ * before setting their host field.
* @param host The new hostname to set
* @return True if the change succeeded, false if it didn't
*/
bool ChangeDisplayedHost(const char* host);
+ /** Change the ident (username) of a user.
+ * ALWAYS use this function, rather than writing userrec::ident directly,
+ * as this correctly causes the user to seem to quit (where configured)
+ * before setting their ident field.
+ * @param host The new ident to set
+ * @return True if the change succeeded, false if it didn't
+ */
+ bool ChangeIdent(const char* newident);
+
/** Change a users realname field.
* ALWAYS use this function, rather than writing userrec::fullname directly,
* as this triggers module events allowing the change to be syncronized to
diff --git a/src/modules/m_chgident.cpp b/src/modules/m_chgident.cpp
index e5b19bfca..3eab361a1 100644
--- a/src/modules/m_chgident.cpp
+++ b/src/modules/m_chgident.cpp
@@ -30,7 +30,8 @@ class cmd_chgident : public command_t
}
ServerInstance->WriteOpers("%s used CHGIDENT to change %s's ident from '%s' to '%s'", user->nick, dest->nick, dest->ident, parameters[1]);
- strlcpy(dest->ident, parameters[1], IDENTMAX+2);
+ dest->ChangeIdent(parameters[1]);
+ //strlcpy(dest->ident, parameters[1], IDENTMAX+2);
}
else
{
diff --git a/src/users.cpp b/src/users.cpp
index 031333dfc..0a213c429 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -1656,6 +1656,29 @@ bool userrec::ChangeDisplayedHost(const char* host)
return true;
}
+bool userrec::ChangeIdent(const char* newident)
+{
+ if (this->ServerInstance->Config->CycleHosts)
+ this->WriteCommonExcept("QUIT :Changing ident");
+
+ strlcpy(this->ident, newident, IDENTMAX+2);
+
+ if (this->ServerInstance->Config->CycleHosts)
+ {
+ for (std::vector<ucrec*>::const_iterator i = this->chans.begin(); i != this->chans.end(); i++)
+ {
+ if ((*i)->channel)
+ {
+ (*i)->channel->WriteAllExceptSender(this, 0, "JOIN %s", (*i)->channel->name);
+ (*i)->channel->WriteChannelWithServ(this->ServerInstance->Config->ServerName, "MODE %s +%s",
+ (*i)->channel->name, this->ServerInstance->Modes->ModeString(this, (*i)->channel).c_str());
+ }
+ }
+ }
+
+ return true;
+}
+
void userrec::NoticeAll(char* text, ...)
{
char textbuffer[MAXBUF];