A staff window in the game, from the report button of a player's card

For staff, the report button of a player's card opens a window for that
player instead (AJClient.openModerate): warn with a reason, send a
message, silence for an hour or a day or lift it, bring them here, go to
them, disconnect, and their warnings. Only what the role allows is shown.

The window sends "xmd" [command, username, ...], which the server runs as
the staff command typed in chat (lib/commands.js), so the permission check
and the moderators' log are the same; the answer comes as a message box.
Only active staff, and only these commands. Staff are sent their role and
permissions at login ("xsp"); nobody else is sent anything.

test/staff.js covers xsp and xmd, and that a player's xmd does nothing.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
SnipzilandClaude Opus 5.5 committed 2026-10-16 22:43:27 -04:00
1 parent 6563d5de99
commit 627e6f9180
5 files changed
+262 -4

No files matched your search

+16
View File
@@ -318,6 +318,11 @@ const login = (session, msg) => {
// and the items staff have made (lib/customitems.js), for a game started
// before they were.
customItems.sendAll(session);
// staff: their role and what it allows, for the patched client's staff
// window (AJClient.onStaff). nobody else is sent anything.
if (roles.isActiveStaff(account)) {
session.sendXt("xsp", -1, roles.roleOf(account), roles.permissionsOf(account).join(","));
}
sendFilter(session);
buddies.announce(account);
};
@@ -459,6 +464,8 @@ const sendUserVars = session => {
};
const findOnline = username => online.get(String(username).toLowerCase());
const STAFF_WINDOW_COMMANDS = ["warn", "message", "silence", "kick", "summon", "goto", "warnings"];
const MAX_STAFF_WINDOW_WORDS = 3; // username, then a reason, hours or the message (each one field)
// a custom colour (lib/colours.js) for these four RGB values, made if it is
// new and the account has not made its day's worth; everyone online is told
@@ -809,6 +816,15 @@ const handlers = {
session.sendXt("fra", -1, fileReport(session, username, reason, "", about) ? 1 : 0);
},
// the staff's window of the patched client (AJClient.openModerate):
// [command, username, ...words], one of the staff commands about a player,
// run as if typed (lib/commands.js checks the permission and logs it).
xmd(session, roomId, [command, ...words]) {
if (roles.isActiveStaff(session.account) && STAFF_WINDOW_COMMANDS.includes(command) && words.length > 0 && words.length <= MAX_STAFF_WINDOW_WORDS) {
commands.run(session, `!${command} ${words.join(" ")}`);
}
},
// the patched report window (gui.ReportAPlayer), just before its "fr" or
// "fra": [username, reasonId, what the reporter typed].
xrd(session, roomId, [username, reason, ...text]) {