|
|
@ -1,8 +1,10 @@
|
|
|
|
const { SerialPort } = require('serialport')
|
|
|
|
const { SerialPort } = require('serialport')
|
|
|
|
const express = require('express')
|
|
|
|
const express = require('express')
|
|
|
|
const app = express()
|
|
|
|
|
|
|
|
const { init, translate, circle, rectangle, to, label } = require("./hpgl.js");
|
|
|
|
|
|
|
|
const tmi = require('tmi.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({
|
|
|
|
const client = new tmi.Client({
|
|
|
|
channels: ['twitchplaysplotter']
|
|
|
|
channels: ['twitchplaysplotter']
|
|
|
@ -57,14 +59,14 @@ app.listen(3000, () => {
|
|
|
|
console.log(`Example app listening on port`)
|
|
|
|
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")) {
|
|
|
|
if (message.toLowerCase().startsWith("lb")) {
|
|
|
|
var words = message.toLowerCase().replace("lb", "");
|
|
|
|
var words = message.toLowerCase().replace("lb", "");
|
|
|
|
toPlotter(label(words));
|
|
|
|
toPlotter(label(words));
|
|
|
|
|
|
|
|
} else if (message.toLowerCase().startsWith("distance")) {
|
|
|
|
|
|
|
|
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
switch (message.toLowerCase()) {
|
|
|
|
switch (message.toLowerCase()) {
|
|
|
|
case 'init':
|
|
|
|
case 'init':
|
|
|
@ -102,4 +104,25 @@ client.on('message', (channel, tags, message, self) => {
|
|
|
|
break;
|
|
|
|
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);
|