[feature] command /anon

This commit is contained in:
方而静 2021-03-26 13:34:23 +08:00
parent 817b00cc4a
commit 1ab04cc557
No known key found for this signature in database
GPG Key ID: C4F2853BC3103681

View File

@ -60,6 +60,7 @@ export function run_command(cmd_raw: string, uid: string, users: Map<string, Use
}; };
const cmd_set = cmd.split(/\s+/); const cmd_set = cmd.split(/\s+/);
const msg = cmd.replace(/^[^\n]+\n/m, '');
if (cmd.startsWith('/disconnect')) { if (cmd.startsWith('/disconnect')) {
command_reply('Diconnecting. Bye!',); command_reply('Diconnecting. Bye!',);
@ -178,4 +179,12 @@ export function run_command(cmd_raw: string, uid: string, users: Map<string, Use
command_reply(JSON.stringify(checked_user)); command_reply(JSON.stringify(checked_user));
} }
if (cmd.startsWith('/anon')) {
io.in(Array.from(socket.rooms)).emit('new message', {
type: 'text-message',
data: msg,
sender: 'Anonymous User',
});
}
}; };