Skip to content

Commit

Permalink
Add /noforcerename
Browse files Browse the repository at this point in the history
Requested by Aeonic.
  • Loading branch information
mia-pi-git committed Oct 11, 2021
1 parent f76bb79 commit febfa9a
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 4 deletions.
41 changes: 38 additions & 3 deletions server/chat-commands/moderation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1730,6 +1730,13 @@ export const commands: Chat.ChatCommands = {
}
return this.errorReply(`User '${inputUsername}' not found. (use /offlineforcerename to rename anyway.)`);
}
if (Punishments.namefilterwhitelist.has(targetID)) {
this.errorReply(`That name is blocked from being forcerenamed.`);
if (user.can('bypassall')) {
this.errorReply(`Use /noforcerename remove to remove it from the list if you wish to rename it.`);
}
return false;
}
this.checkCan('forcerename', targetID);
const {publicReason, privateReason} = this.parseSpoiler(reason);

Expand Down Expand Up @@ -1764,16 +1771,44 @@ export const commands: Chat.ChatCommands = {
);

targetUser?.resetName(true);
if (Punishments.namefilterwhitelist.has(targetID)) {
Punishments.unwhitelistName(targetID);
}
return true;
},
forcerenamehelp: [
`/forcerename OR /fr [username], [reason] - Forcibly change a user's name and shows them the [reason]. Requires: % @ &`,
`/allowname [username] - Unmarks a forcerenamed username, stopping staff from being notified when it is used. Requires % @ &`,
],

nfr: 'noforcerename',
noforcerename: {
add(target, room, user) {
const {targetUsername, rest} = this.splitUser(target);
const targetId = toID(targetUsername);
if (!targetId) return this.parse('/help noforcerename');
this.checkCan('bypassall');
if (!Punishments.whitelistName(target, user.name)) {
return this.errorReply(`${targetUsername} is already on the noforcerename list.`);
}
this.addGlobalModAction(`${user.name} added the name ${targetId} to the no forcerename list.${rest ? ` (${rest})` : ''}`);
this.globalModlog('NOFORCERENAME', targetId, rest);
},
remove(target, room, user) {
const {targetUsername, rest} = this.splitUser(target);
const targetId = toID(targetUsername);
if (!targetId) return this.parse('/help noforcerename');
this.checkCan('bypassall');
if (!Punishments.namefilterwhitelist.has(targetId)) {
return this.errorReply(`${targetUsername} is not on the noforcerename list.`);
}
Punishments.unwhitelistName(target);
this.addGlobalModAction(`${user.name} removed ${targetId} from the no forcerename list.${rest ? ` (${rest})` : ''}`);
this.globalModlog('UNNOFORCERENAME', targetId, rest);
},
},
noforcerenamehelp: [
`/noforcerename add OR /nfr add [username] - Adds [username] to the list of users who can't be forcerenamed by staff.`,
`/noforcerename remove OR /nfr remove [username] - Removes [username] from the list of users who can't be forcerenamed by staff.`,
],

forceclearstatus(target, room, user) {
const {targetUser, rest: reason} = this.requireUser(target, {allowOffline: true});
this.checkCan('forcerename', targetUser);
Expand Down
3 changes: 2 additions & 1 deletion server/chat-plugins/chat-monitor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,7 @@ export const commands: Chat.ChatCommands = {
this.checkCan('forcerename');
target = toID(target);
if (!target) return this.errorReply(`Syntax: /allowname username`);
if (!Punishments.whitelistName(target, user.name)) {
if (Punishments.namefilterwhitelist.has(target)) {
return this.errorReply(`${target} is already allowed as a username.`);
}

Expand All @@ -776,6 +776,7 @@ export const commands: Chat.ChatCommands = {
this.sendReply(msg);
}
this.globalModlog(`ALLOWNAME`, target);
Monitor.forceRenames.delete(target as ID);
},
};

Expand Down

0 comments on commit febfa9a

Please sign in to comment.