mirror of
https://github.com/lklynet/hypermind.git
synced 2026-05-03 17:40:29 +00:00
7303f605ac
- Add `/who` command to list active users via new `/api/peers` endpoint - Implement graceful shutdown for server and swarm with proper cleanup - Enhance SSE broadcast with client connection state checks - Expose peer list in stats and add health endpoint - Fix theme color refresh for network visualization
78 lines
2.5 KiB
JavaScript
78 lines
2.5 KiB
JavaScript
export const helpCommand = {
|
|
description: "Shows available commands",
|
|
execute: () => {
|
|
const output = document.getElementById("terminal-output");
|
|
if (!output) return;
|
|
|
|
const createHelpSection = (title, items) => {
|
|
const section = document.createElement("div");
|
|
section.style.marginBottom = "10px";
|
|
section.style.color = "#aaa";
|
|
|
|
const header = document.createElement("div");
|
|
header.style.fontWeight = "bold";
|
|
header.style.color = "#fff";
|
|
header.style.marginBottom = "4px";
|
|
header.innerText = title;
|
|
section.appendChild(header);
|
|
|
|
items.forEach((item) => {
|
|
const div = document.createElement("div");
|
|
div.innerHTML = `<span style="color: #4ade80">${item.cmd}</span> - ${item.desc}`;
|
|
section.appendChild(div);
|
|
});
|
|
|
|
return section;
|
|
};
|
|
|
|
const helpContainer = document.createElement("div");
|
|
helpContainer.className = "system-message";
|
|
helpContainer.style.padding = "10px";
|
|
helpContainer.style.borderTop = "1px dashed #333";
|
|
helpContainer.style.borderBottom = "1px dashed #333";
|
|
helpContainer.style.margin = "10px 0";
|
|
|
|
// system
|
|
const systemCmds = [
|
|
{
|
|
cmd: "/whisper <user> <msg>",
|
|
desc: "Send a private message",
|
|
},
|
|
{ cmd: "/block <user>", desc: "Block messages from a user" },
|
|
{ cmd: "/unblock <user>", desc: "Unblock a user" },
|
|
{ cmd: "/who", desc: "List active users in the swarm" },
|
|
{
|
|
cmd: "/local <msg>",
|
|
desc: "Send message to direct peers only (Global by default)",
|
|
},
|
|
{ cmd: "/clear", desc: "Clear chat history" },
|
|
{ cmd: "/timestamp", desc: "Toggle timestamps" },
|
|
{ cmd: "/sound", desc: "Toggle sound effects" },
|
|
{ cmd: "/help", desc: "Show this help menu" },
|
|
];
|
|
helpContainer.appendChild(createHelpSection("System Commands", systemCmds));
|
|
|
|
// Formatting
|
|
const formatCmds = [
|
|
{ cmd: "**text**", desc: "Bold" },
|
|
{ cmd: "*text*", desc: "Italics" },
|
|
{ cmd: "__text__", desc: "Underline" },
|
|
{ cmd: "~~text~~", desc: "Strikethrough" },
|
|
{ cmd: "`text`", desc: "Code" },
|
|
];
|
|
helpContainer.appendChild(createHelpSection("Formatting", formatCmds));
|
|
|
|
// Easter Eggs
|
|
const eggs = Object.entries(window.ChatCommands.replacements).map(
|
|
([k, v]) => ({
|
|
cmd: k,
|
|
desc: v,
|
|
})
|
|
);
|
|
helpContainer.appendChild(createHelpSection("Easter Eggs", eggs));
|
|
|
|
output.appendChild(helpContainer);
|
|
output.scrollTop = output.scrollHeight;
|
|
},
|
|
};
|