Add server chat slash commands for me and uptime

This commit is contained in:
Jage9
2026-02-27 04:33:54 -05:00
parent 10e7a01e73
commit 464d39f78b
9 changed files with 179 additions and 2 deletions

View File

@@ -40,6 +40,10 @@
"keys": "Slash",
"description": "Start chat"
},
{
"keys": "Slash commands",
"description": "In chat, use /me <action> for action text or /up for server uptime"
},
{
"keys": "Comma / Period",
"description": "Previous/next message"

View File

@@ -1,5 +1,5 @@
// Maintainer-controlled web client version.
// Format: YYYY.MM.DD Rn (example: 2026.02.20 R2)
window.CHGRID_WEB_VERSION = "2026.02.27 R292";
window.CHGRID_WEB_VERSION = "2026.02.27 R293";
// Optional display timezone for timestamps. Falls back to America/Detroit if unset/invalid.
window.CHGRID_TIME_ZONE = "America/Detroit";

View File

@@ -238,6 +238,7 @@ const SYSTEM_SOUND_URLS = {
logout: withBase('sounds/logout.ogg'),
notify: withBase('sounds/notify.ogg'),
} as const;
const ACTION_SOUND_URL = SYSTEM_SOUND_URLS.notify;
const FOOTSTEP_SOUND_URLS = Array.from({ length: 11 }, (_, index) => withBase(`sounds/step-${index + 1}.ogg`));
const FOOTSTEP_GAIN = 0.7;
const TELEPORT_START_SOUND_URL = withBase('sounds/teleport_start.ogg');
@@ -1820,6 +1821,7 @@ const onAppMessage = createOnMessageHandler({
getAudioLayers: () => audioLayers,
pushChatMessage,
classifySystemMessageSound,
ACTION_SOUND_URL,
SYSTEM_SOUND_URLS,
playSample: (url, gain = 1) => {
void audio.playSample(url, gain);

View File

@@ -54,6 +54,7 @@ type MessageHandlerDeps = {
getAudioLayers: () => { world: boolean; item: boolean };
pushChatMessage: (message: string) => void;
classifySystemMessageSound: (message: string) => 'logon' | 'logout' | 'notify' | null;
ACTION_SOUND_URL: string;
SYSTEM_SOUND_URLS: { logon: string; logout: string; notify: string };
playSample: (url: string, gain?: number) => void;
updateStatus: (message: string) => void;
@@ -225,7 +226,10 @@ export function createOnMessageHandler(deps: MessageHandlerDeps): (message: Inco
}
case 'chat_message': {
if (message.system) {
if (message.action) {
deps.pushChatMessage(message.message);
deps.playSample(deps.ACTION_SOUND_URL, 1);
} else if (message.system) {
deps.pushChatMessage(message.message);
const sound = deps.classifySystemMessageSound(message.message);
if (sound) {

View File

@@ -185,6 +185,7 @@ export const chatMessageSchema = z.object({
senderId: z.string().optional(),
senderNickname: z.string().optional(),
system: z.boolean().optional(),
action: z.boolean().optional(),
});
export const pongSchema = z.object({