- OnRehash(NULL);
- Implementation eventlist[] = {
- I_OnRehash, I_OnUserRegister, I_OnCheckReady,
- I_OnUserDisconnect, I_OnSetConnectClass
- };
- ServerInstance->Modules->Attach(eventlist, this, 5);
+ // Check that they haven't been prefixed already.
+ if (user->ident[0] == '~')
+ return;
+
+ // All invalid usernames are prefixed with a tilde.
+ std::string newident(user->ident);
+ newident.insert(newident.begin(), '~');
+
+ // If the username is too long then truncate it.
+ if (newident.length() > ServerInstance->Config->Limits.IdentMax)
+ newident.erase(ServerInstance->Config->Limits.IdentMax);
+
+ // Apply the new username.
+ user->ChangeIdent(newident);