Various status improvements (#5573)

* Allow staff to clear statuses

* Check banwords in a better way

* Don't inline setstatus

* Handle an edge case when clearing statuses
This commit is contained in:
whales
2019-07-03 01:03:23 +09:30
committed by Bär Halberkamp
parent 836fc71c00
commit 35a8eebce2
2 changed files with 23 additions and 10 deletions

View File

@@ -658,7 +658,7 @@ const commands = {
if (!this.canTalk()) return;
if (!target) return this.parse('/help status');
target = Chat.namefilter(target, user, true);
if (!target) return;
if (!target) return user.popup("Your status contains a banned word.");
let statusType = '(Online)';
// Should work even if users use /status with a message containing ()
@@ -666,8 +666,7 @@ const commands = {
statusType = user.status.slice(0, user.status.indexOf(')') + 1);
}
user.status = `${statusType} ${target}`;
user.updateIdentity();
user.setStatus(`${statusType} ${target}`);
this.sendReply(`Your status has been set to: ${target}`);
},
statushelp: [`/status [note] - Sets a short note as your status, visible when users click your username.`],
@@ -677,10 +676,9 @@ const commands = {
if (!this.canTalk()) return;
let message = Chat.namefilter(target, user, true);
if (!message && target) return user.popup("Your status contains a banned word.");
const busyMessage = `(Busy)${message ? ` ${message}` : ''}`;
user.status = busyMessage;
user.updateIdentity();
user.setStatus(`(Busy)${message ? ` ${message}` : ''}`);
this.parse('/blockpms');
this.parse('/blockchallenges');
this.sendReply("You are now marked as busy.");
@@ -702,7 +700,7 @@ const commands = {
}
if (target) {
awayMessage = Chat.namefilter(target, user, true);
if (!awayMessage) return;
if (!awayMessage) return user.popup("Your status contains a banned word.");
}
awayMessage = `(${awayType})${awayMessage ? ` ${awayMessage}` : ''}`;
@@ -716,6 +714,23 @@ const commands = {
unaway: 'back',
unafk: 'back',
back(target, room, user) {
if (target) {
// Clearing another user's status
let reason = this.splitTarget(target);
let targetUser = this.targetUser;
if (!targetUser) return this.errorReply(`User '${target}' not found.`);
if (!targetUser.status) return this.errorReply(`${targetUser.name} does not have a status set.`);
if (!this.can('forcerename', targetUser)) return false;
let bracketIndex = targetUser.status.indexOf(')');
if (bracketIndex < 0) bracketIndex = -2; // Someone's trying to clear the "Idle" status, for some reason
const status = targetUser.status.slice(bracketIndex + 2);
this.privateModAction(`(${targetUser.name}'s status "${status}" was cleared by ${user.name}${reason ? `: ${reason}` : ``})`);
this.globalModlog('CLEARSTATUS', targetUser, `from ${status} by ${user.name}${reason ? `: ${reason}` : ``}`);
targetUser.clearStatus();
targetUser.popup(`${user.name} has cleared your status for being inappropriate${reason ? `: ${reason}` : '.'}`);
return;
}
if (!user.status) return;
const statusType = user.isAway() ? 'away' : user.status.startsWith('(Busy)') ? 'busy' : null;
user.clearStatus();

View File

@@ -248,9 +248,7 @@ let namefilter = function (name, user, forStatus) {
if (matched) {
if (Chat.monitors[list].punishment === 'AUTOLOCK') {
Punishments.autolock(user, Rooms('staff'), `NameMonitor`, `inappropriate name: ${name}`, `using an inappropriate name: ${name} (from ${user.name})`, false, name);
} else if (forStatus) {
user.popup("Your status contains a banned word.");
} else {
} else if (!forStatus) {
user.trackRename = name;
}
line[3]++;