Add twitch chat receiving

master
Nyxaeroz 10 months ago
parent f6f69d6f62
commit 1f34e0c240

@ -6,7 +6,7 @@ const movement = 1000;
// Create a port
const port = new SerialPort({
path: '/dev/ttyUSB1',
path: '/dev/ttyUSB0',
baudRate: 9600,
})
@ -93,3 +93,42 @@ app.listen(3000, () => {
console.log(`Example app listening on port`)
})
const tmi = require('tmi.js');
const client = new tmi.Client({
channels: [ 'twitchplaysplotter' ]
});
client.connect();
client.on('message', (channel, tags, message, self) => {
console.log(`${tags['display-name']}: ${message}`);
switch ( message.toLowerCase() ) {
case 'pu':
console.log("Performing a PU");
break;
case 'pd':
console.log("Performing a PD");
break;
case 'up':
console.log("Performing a move UP");
break;
case 'down':
console.log("Performing a move DOWN");
break;
case 'left':
console.log("Performing a move LEFT");
break;
case 'right':
console.log("Performing a move RIGHT");
break;
default:
console.log("Message not recognized");
toPlotter(`IN;SC0,0,100,0,100;SP1;PA60,60;PU`)
break;
}
});

1732
package-lock.json generated

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save