From 4768cc4c7b8cdcf4c3e6348fa4dd14caec3170ca Mon Sep 17 00:00:00 2001
From: Austin Couturier
Date: Sat, 3 Feb 2018 14:56:25 -0700
Subject: [PATCH] Suggest users to use /blacklistname in blacklist error reply
(#4396)
---
chat-commands.js | 45 ++++++++++++++++++++++++---------------------
1 file changed, 24 insertions(+), 21 deletions(-)
diff --git a/chat-commands.js b/chat-commands.js
index 9953a91630..836cd44ff3 100644
--- a/chat-commands.js
+++ b/chat-commands.js
@@ -1398,8 +1398,8 @@ exports.commands = {
let curRoom = targetRoom;
while (curRoom.parent) {
const modjoinSetting = curRoom.modjoin === true ? curRoom.modchat : curRoom.modjoin;
- const roomType = (modjoinSetting ? `modjoin ${modjoinSetting} ` : ``);
- const inheritedUserType = (modjoinSetting ? ` of rank ${modjoinSetting} and above` : ``);
+ const roomType = (modjoinSetting ? `modjoin ${modjoinSetting} ` : '');
+ const inheritedUserType = (modjoinSetting ? ` of rank ${modjoinSetting} and above` : '');
if (curRoom.parent) {
buffer.push(`${curRoom.title} is a ${roomType}subroom of ${curRoom.parent.title}, so ${curRoom.parent.title} users${inheritedUserType} also have authority in this room.`);
}
@@ -1503,7 +1503,7 @@ exports.commands = {
);
}
- const reason = (target ? ` (${target})` : ``);
+ const reason = (target ? ` (${target})` : '');
this.addModAction(`${name} was banned from ${room.title} by ${user.name}.${reason}`);
let affected = Punishments.roomBan(room, targetUser, null, null, target);
@@ -1830,7 +1830,7 @@ exports.commands = {
this.add(`|unlink|hide|${userid}`);
if (userid !== toId(this.inputUsername)) this.add(`|unlink|hide|${toId(this.inputUsername)}`);
- const globalReason = (target ? `: ${userReason} ${proof}` : ``);
+ const globalReason = (target ? `: ${userReason} ${proof}` : '');
this.globalModlog((week ? "WEEKLOCK" : "LOCK"), targetUser || userid, ` by ${user.userid}${globalReason}`);
// Automatically upload replays as evidence/reference to the punishment
@@ -1953,7 +1953,7 @@ exports.commands = {
this.add('|unlink|hide|' + userid);
if (userid !== toId(this.inputUsername)) this.add('|unlink|hide|' + toId(this.inputUsername));
- const globalReason = (target ? `: ${userReason} ${proof}` : ``);
+ const globalReason = (target ? `: ${userReason} ${proof}` : '');
this.globalModlog("BAN", targetUser, ` by ${user.userid}${globalReason}`);
return true;
},
@@ -2450,41 +2450,44 @@ exports.commands = {
blacklist: function (target, room, user) {
if (!target) return this.parse('/help blacklist');
if (!this.canTalk()) return;
- if (toId(target) === 'show') return this.errorReply("You're looking for /showbl");
+ if (toId(target) === 'show') return this.errorReply(`You're looking for /showbl`);
target = this.splitTarget(target);
const targetUser = this.targetUser;
- if (!targetUser) return this.errorReply("User '" + this.targetUsername + "' not found.");
+ if (!targetUser) {
+ this.errorReply(`User ${this.targetUsername} not found.`);
+ return this.errorReply(`If you want to blacklist an offline account by name (not IP), consider /blacklistname`);
+ }
if (!this.can('editroom', targetUser, room)) return false;
if (!room.chatRoomData) {
- return this.errorReply("This room is not going to last long enough for a blacklist to matter - just ban the user");
+ return this.errorReply(`This room is not going to last long enough for a blacklist to matter - just ban the user`);
}
let punishment = Punishments.isRoomBanned(targetUser, room.id);
if (punishment && punishment[0] === 'BLACKLIST') {
- return this.errorReply("This user is already blacklisted from this room.");
+ return this.errorReply(`This user is already blacklisted from this room.`);
}
if (!target) {
- return this.errorReply("Blacklists require a reason.");
+ return this.errorReply(`Blacklists require a reason.`);
}
if (target.length > MAX_REASON_LENGTH) {
- return this.errorReply("The reason is too long. It cannot exceed " + MAX_REASON_LENGTH + " characters.");
+ return this.errorReply(`The reason is too long. It cannot exceed ${MAX_REASON_LENGTH} characters.`);
}
const name = targetUser.getLastName();
const userid = targetUser.getLastId();
if (targetUser.trusted && room.isPrivate !== true) {
- Monitor.log("[CrisisMonitor] Trusted user " + targetUser.name + (targetUser.trusted !== targetUser.userid ? " (" + targetUser.trusted + ")" : "") + " was blacklisted from " + room.id + " by " + user.name + ", and should probably be demoted.");
+ Monitor.log(`[CrisisMonitor] Trusted user ${targetUser.name}${(targetUser.trusted !== targetUser.userid ? ` (${targetUser.trusted})` : '')} was blacklisted from ${room.id} by ${user.name}, and should probably be demoted.`);
}
if (targetUser in room.users || user.can('lock')) {
targetUser.popup(
- "|modal||html|
" + Chat.escapeHTML(user.name) + " has blacklisted you from the room " + room.id + (room.subRooms ? " and its subrooms" : "") + ".
" + (target ? "
Reason: " + Chat.escapeHTML(target) + "
" : "") +
- "
To appeal the ban, PM the staff member that blacklisted you" + (!room.battle && room.auth ? " or a room owner.
" : ".
")
+ `|modal||html|
${Chat.escapeHTML(user.name)} has blacklisted you from the room ${room.id}${(room.subRooms ? ` and its subrooms` : '')}. Reason: ${Chat.escapeHTML(target)}
` +
+ `
To appeal the ban, PM the staff member that blacklisted you${(!room.battle && room.auth ? ` or a room owner.
` : `.`)}`
);
}
- this.addModAction(`${name} was blacklisted from ${room.title} by ${user.name}. ${(target ? ` (${target})` : ``)}`);
+ this.addModAction(`${name} was blacklisted from ${room.title} by ${user.name}. ${(target ? ` (${target})` : '')}`);
let affected = Punishments.roomBlacklist(room, targetUser, null, null, target);
@@ -2492,18 +2495,18 @@ exports.commands = {
let acAccount = (targetUser.autoconfirmed !== userid && targetUser.autoconfirmed);
let displayMessage = '';
if (affected.length > 1) {
- displayMessage = "(" + name + "'s " + (acAccount ? " ac account: " + acAccount + ", " : "") + "blacklisted alts: " + affected.slice(1).map(user => user.getLastName()).join(", ") + ")";
+ displayMessage = `(${name}'s ${(acAccount ? ` ac account: ${acAccount},` : '')} blacklisted alts: ${affected.slice(1).map(user => user.getLastName()).join(", ")})`;
this.privateModAction(displayMessage);
} else if (acAccount) {
- displayMessage = "(" + name + "'s ac account: " + acAccount + ")";
+ displayMessage = `(${name}'s ac account: ${acAccount})`;
this.privateModAction(displayMessage);
}
}
- this.add('|unlink|hide|' + userid);
- if (userid !== toId(this.inputUsername)) this.add('|unlink|hide|' + toId(this.inputUsername));
+ this.add(`|unlink|hide|${userid}`);
+ if (userid !== toId(this.inputUsername)) this.add(`|unlink|hide|${toId(this.inputUsername)}`);
if (!room.isPrivate && room.chatRoomData) {
- this.globalModlog("BLACKLIST", targetUser, " by " + user.userid + (target ? ": " + target : ""));
+ this.globalModlog("BLACKLIST", targetUser, ` by ${user.userid} ${(target ? `: ${target}` : '')}`);
}
return true;
},
@@ -2634,7 +2637,7 @@ exports.commands = {
}
let soonExpiring = (cmd === 'expiringblacklists' || cmd === 'expiringbls');
- let buf = Chat.html`Blacklist for ${room.title}${soonExpiring ? ` (expiring within 3 months)` : ``}: `;
+ let buf = Chat.html`Blacklist for ${room.title}${soonExpiring ? ` (expiring within 3 months)` : ''}: `;
blMap.forEach((data, userid) => {
const [expireTime, ...alts] = data;