|
|
|
@ -1,8 +1,10 @@
|
|
|
|
|
const { SerialPort } = require('serialport')
|
|
|
|
|
const express = require('express')
|
|
|
|
|
const app = express()
|
|
|
|
|
const { init, translate, circle, rectangle, to, label } = require("./hpgl.js");
|
|
|
|
|
const tmi = require('tmi.js');
|
|
|
|
|
const { init, translate, circle, rectangle, to, label } = require("./hpgl.js");
|
|
|
|
|
|
|
|
|
|
const distance = 3;
|
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
|
|
const client = new tmi.Client({
|
|
|
|
|
channels: ['twitchplaysplotter']
|
|
|
|
@ -57,14 +59,14 @@ app.listen(3000, () => {
|
|
|
|
|
console.log(`Example app listening on port`)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
client.on('message', (channel, tags, message, self) => {
|
|
|
|
|
const distance = 3;
|
|
|
|
|
|
|
|
|
|
console.log(`${tags['display-name']}: ${message}`);
|
|
|
|
|
const parseMessage = (message) => {
|
|
|
|
|
|
|
|
|
|
if (message.toLowerCase().startsWith("lb")) {
|
|
|
|
|
var words = message.toLowerCase().replace("lb", "");
|
|
|
|
|
toPlotter(label(words));
|
|
|
|
|
} else if (message.toLowerCase().startsWith("distance")) {
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
switch (message.toLowerCase()) {
|
|
|
|
|
case 'init':
|
|
|
|
@ -102,4 +104,25 @@ client.on('message', (channel, tags, message, self) => {
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
client.on('message', (channel, tags, message, self) => {
|
|
|
|
|
|
|
|
|
|
console.log(`${tags['display-name']}: ${message}`);
|
|
|
|
|
parseMessage(message)
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var testMessages = ['init','pu','pd','up','down','left','right','right','rectangle','circle','LBhaihai'];
|
|
|
|
|
var testIndex = 0;
|
|
|
|
|
var interval = setInterval(function () {
|
|
|
|
|
console.log("----- about to send a test message: ", testMessages[testIndex]);
|
|
|
|
|
parseMessage(testMessages[testIndex]);
|
|
|
|
|
|
|
|
|
|
if(testIndex < (testMessages.length - 1)) {
|
|
|
|
|
testIndex++;
|
|
|
|
|
} else {
|
|
|
|
|
console.log("completed the test")
|
|
|
|
|
clearInterval(interval);
|
|
|
|
|
}
|
|
|
|
|
}, 1000);
|