Check for own device id and use Switch instead of if/else
This commit is contained in:
parent
20da71d040
commit
3d4edc1fd4
@ -122,10 +122,19 @@ async function processor(group, consumer, streamKey) {
|
|||||||
|
|
||||||
for (const stream of res) {
|
for (const stream of res) {
|
||||||
for (const msg of stream.messages) {
|
for (const msg of stream.messages) {
|
||||||
|
if (msg.message.device_id !== config.DEVICE_ID) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
console.log(`[${consumer}] Processing:`, msg);
|
console.log(`[${consumer}] Processing:`, msg);
|
||||||
|
|
||||||
if (msg.message.command === "play_music") {
|
switch (msg.message.command) {
|
||||||
await playAudio("Playing music.");
|
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);
|
await redis.client.xAck(streamKey, group, msg.id);
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user