mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
Merge pull request #105 from MinusGix/change_nick_case
Modify changenick to allow the changing of the name's case
This commit is contained in:
commit
4e59a3a1e2
|
@ -18,6 +18,8 @@ export async function run(core, server, socket, data) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const previousNick = socket.nick;
|
||||||
|
|
||||||
// make sure requested nickname meets standards
|
// make sure requested nickname meets standards
|
||||||
const newNick = data.nick.trim();
|
const newNick = data.nick.trim();
|
||||||
if (!UAC.verifyNickname(newNick)) {
|
if (!UAC.verifyNickname(newNick)) {
|
||||||
|
@ -38,10 +40,19 @@ export async function run(core, server, socket, data) {
|
||||||
}, socket);
|
}, socket);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (newNick == previousNick) {
|
||||||
|
return server.reply({
|
||||||
|
cmd: 'warn',
|
||||||
|
text: 'You already have that name',
|
||||||
|
}, socket);
|
||||||
|
}
|
||||||
|
|
||||||
// find any sockets that have the same nickname
|
// find any sockets that have the same nickname
|
||||||
const userExists = server.findSockets({
|
const userExists = server.findSockets({
|
||||||
channel: socket.channel,
|
channel: socket.channel,
|
||||||
nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase(),
|
nick: (targetNick) => targetNick.toLowerCase() === newNick.toLowerCase() &&
|
||||||
|
// Allow them to rename themselves to a different case
|
||||||
|
targetNick != previousNick,
|
||||||
});
|
});
|
||||||
|
|
||||||
// return error if found
|
// return error if found
|
||||||
|
|
Loading…
Reference in New Issue
Block a user