Check for own device id and use Switch instead of if/else

This commit is contained in:
Apher 2026-07-16 01:11:13 +00:00
parent 20da71d040
commit 3d4edc1fd4

View File

@ -122,10 +122,19 @@ async function processor(group, consumer, streamKey) {
for (const stream of res) {
for (const msg of stream.messages) {
if (msg.message.device_id !== config.DEVICE_ID) {
continue
}
console.log(`[${consumer}] Processing:`, msg);
if (msg.message.command === "play_music") {
await playAudio("Playing music.");
switch (msg.message.command) {
case "greeting":
await playAudio("Hello! I am the Many Tailed Fox.");
break;
default:
await playAudio("Command, " + String(msg.message.command) + " is undefined.")
}
await redis.client.xAck(streamKey, group, msg.id);