mirror of
https://github.com/smogon/pokemon-showdown.git
synced 2026-09-10 02:05:35 -05:00
Introduce /unlockname and redesign /unlockip (#4869)
- Allow unlocking specific names with /unlockname - Expand /unlockip to work for mods - Clarify which names are locked on /ip
This commit is contained in:
committed by
Guangcong Luo
parent
63ad3559f4
commit
2accf99e7f
@@ -1902,6 +1902,53 @@ const commands = {
|
||||
this.errorReply(`User '${target}' is not locked.`);
|
||||
}
|
||||
},
|
||||
unlockname: function (target, room, user) {
|
||||
if (!target) return this.parse('/help unlock');
|
||||
if (!this.can('lock')) return false;
|
||||
|
||||
const userid = toId(target);
|
||||
const punishment = Punishments.userids.get(userid);
|
||||
if (!punishment) return this.errorReply("This name isn't locked.");
|
||||
if (punishment[1] === userid) return this.errorReply(`"${userid}" was specifically locked by a staff member (check the global modlog). Use /unlock if you really want to unlock this name.`);
|
||||
|
||||
Punishments.userids.delete(userid);
|
||||
Punishments.savePunishments();
|
||||
|
||||
for (const curUser of Users.findUsers([userid], [])) {
|
||||
if (curUser.locked && !curUser.locked.startsWith('#') && !Punishments.getPunishType(curUser.userid)) {
|
||||
curUser.locked = false;
|
||||
curUser.namelocked = false;
|
||||
curUser.updateIdentity();
|
||||
}
|
||||
}
|
||||
this.globalModlog("UNLOCKNAME", userid, ` by ${user.name}`);
|
||||
this.addModAction(`The name '${target}' was unlocked by ${user.name}.`);
|
||||
},
|
||||
unlockip: function (target, room, user) {
|
||||
target = target.trim();
|
||||
if (!target) return this.parse('/help unlock');
|
||||
if (!this.can('ban')) return false;
|
||||
const range = target.charAt(target.length - 1) === '*';
|
||||
if (range && !this.can('rangeban')) return false;
|
||||
|
||||
if (!/^[0-9.*]+$/.test(target)) return this.errorReply("Please enter a valid IP address.");
|
||||
|
||||
const punishment = Punishments.ips.get(target);
|
||||
if (!punishment) return this.errorReply(`${target} is not a locked/banned IP or IP range.`);
|
||||
|
||||
Punishments.ips.delete(target);
|
||||
Punishments.savePunishments();
|
||||
|
||||
for (const curUser of Users.findUsers([], [target])) {
|
||||
if (curUser.locked && !curUser.locked.startsWith('#') && !Punishments.getPunishType(curUser.userid)) {
|
||||
curUser.locked = false;
|
||||
curUser.namelocked = false;
|
||||
curUser.updateIdentity();
|
||||
}
|
||||
}
|
||||
this.globalModlog(`UNLOCK${range ? 'RANGE' : 'IP'}`, target, ` by ${user.name}`);
|
||||
this.addModAction(`${user.name} unlocked the ${range ? "IP range" : "IP"}: ${target}`);
|
||||
},
|
||||
unlockhelp: [`/unlock [username] - Unlocks the user. Requires: % @ * & ~`],
|
||||
|
||||
forceglobalban: 'globalban',
|
||||
@@ -2123,19 +2170,6 @@ const commands = {
|
||||
|
||||
unrangelock: 'unlockip',
|
||||
rangeunlock: 'unlockip',
|
||||
unlockip: function (target, room, user) {
|
||||
target = target.trim();
|
||||
if (!target) {
|
||||
return this.parse('/help unbanip');
|
||||
}
|
||||
if (!this.can('rangeban')) return false;
|
||||
if (!Punishments.ips.has(target)) {
|
||||
return this.errorReply(`${target} is not a locked/banned IP or IP range.`);
|
||||
}
|
||||
Punishments.ips.delete(target);
|
||||
this.addModAction(`${user.name} unlocked the ${(target.charAt(target.length - 1) === '*' ? "IP range" : "IP")}: ${target}`);
|
||||
this.modlog('UNRANGELOCK', null, target);
|
||||
},
|
||||
|
||||
/*********************************************************
|
||||
* Moderating: Other
|
||||
|
||||
@@ -84,16 +84,24 @@ const commands = {
|
||||
}
|
||||
buf += '<br />';
|
||||
if (user.can('alts', targetUser) || user.can('alts') && user === targetUser) {
|
||||
let prevNames = Object.keys(targetUser.prevNames).join(", ");
|
||||
let prevNames = Object.keys(targetUser.prevNames).map(userid => {
|
||||
const punishment = Punishments.userids.get(userid);
|
||||
return userid + (punishment ? ` (${Punishments.punishmentTypes.get(punishment[0]) || 'punished'}${punishment[1] !== targetUser.userid ? ` as ${punishment[1]}` : ''})` : '');
|
||||
}).join(", ");
|
||||
if (prevNames) buf += Chat.html`<br />Previous names: ${prevNames}`;
|
||||
|
||||
for (const targetAlt of targetUser.getAltUsers(true)) {
|
||||
if (!targetAlt.named && !targetAlt.connected) continue;
|
||||
if (targetAlt.group === '~' && user.group !== '~') continue;
|
||||
|
||||
buf += Chat.html`<br />Alt: <span class="username">${targetAlt.name}</span>`;
|
||||
const punishment = Punishments.userids.get(targetAlt.userid);
|
||||
const punishMsg = punishment ? ` (${Punishments.punishmentTypes.get(punishment[0]) || 'punished'}${punishment[1] !== targetAlt.userid ? ` as ${punishment[1]}` : ''})` : '';
|
||||
buf += Chat.html`<br />Alt: <span class="username">${targetAlt.name}${punishMsg}</span>`;
|
||||
if (!targetAlt.connected) buf += ` <em style="color:gray">(offline)</em>`;
|
||||
prevNames = Object.keys(targetAlt.prevNames).join(", ");
|
||||
prevNames = Object.keys(targetAlt.prevNames).map(userid => {
|
||||
const punishment = Punishments.userids.get(userid);
|
||||
return userid + (punishment ? ` (${Punishments.punishmentTypes.get(punishment[0]) || 'punished'}${punishment[1] !== targetAlt.userid ? ` as ${punishment[1]}` : ''})` : '');
|
||||
}).join(", ");
|
||||
if (prevNames) buf += `<br />Previous names: ${prevNames}`;
|
||||
}
|
||||
if (targetUser.namelocked) {
|
||||
|
||||
Reference in New Issue
Block a user