Refactor command handling in broadcast.js to streamline input processing. Moved command validation and parsing logic to ensure proper handling of user inputs during chat login and command execution.

This commit is contained in:
Torsten Schulz (local)
2026-03-19 13:54:14 +01:00
parent bcb3b5b71f
commit 51040391e8

View File

@@ -536,11 +536,6 @@ export function setupBroadcast(io, __dirname) {
function executeCommand(socket, client, rawInput) { function executeCommand(socket, client, rawInput) {
const input = rawInput.trim(); const input = rawInput.trim();
if (!input.startsWith('/')) return false;
const parts = input.split(/\s+/);
const command = parts[0].toLowerCase();
// Laufender Login-Dialog: Nur Eingaben ohne Slash als Username/Passwort behandeln. // Laufender Login-Dialog: Nur Eingaben ohne Slash als Username/Passwort behandeln.
if (client.pendingChatLogin && !input.startsWith('/')) { if (client.pendingChatLogin && !input.startsWith('/')) {
if (client.pendingChatLogin.step === 'username') { if (client.pendingChatLogin.step === 'username') {
@@ -578,6 +573,11 @@ export function setupBroadcast(io, __dirname) {
// und läuft unten als normaler Befehl weiter // und läuft unten als normaler Befehl weiter
} }
if (!input.startsWith('/')) return false;
const parts = input.split(/\s+/);
const command = parts[0].toLowerCase();
if (command === '/login') { if (command === '/login') {
const username = (parts[1] || '').trim(); const username = (parts[1] || '').trim();
if (username) { if (username) {