monitor/core/modules/WebServer/wsRooms/liveconsole.ts
2025-04-16 22:30:27 +07:00

31 lines
1020 B
TypeScript

import type { RoomType } from "../webSocket";
import { AuthedAdminType } from "../authLogic";
/**
* The console room is responsible for the server live console page
*/
export default {
permission: 'console.view',
eventName: 'consoleData',
cumulativeBuffer: true,
outBuffer: '',
initialData: () => txCore.logger.fxserver.getRecentBuffer(),
commands: {
consoleCommand: {
permission: 'console.write',
handler: (admin: AuthedAdminType, command: string) => {
if(typeof command !== 'string' || !command) return;
const sanitized = command.replaceAll(/\n/g, ' ');
admin.logCommand(sanitized);
txCore.fxRunner.sendRawCommand(sanitized, admin.name);
txCore.fxRunner.sendEvent('consoleCommand', {
channel: 'txAdmin',
command: sanitized,
author: admin.name,
});
}
},
},
} satisfies RoomType;