parent
e78428c94d
commit
60fdea6d5b
|
@ -0,0 +1,149 @@
|
|||
{
|
||||
"name": "hello-express",
|
||||
"version": "0.0.1",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "4.3.0",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz",
|
||||
"integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==",
|
||||
"requires": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
}
|
||||
},
|
||||
"async-limiter": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
|
||||
"integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ=="
|
||||
},
|
||||
"es6-promise": {
|
||||
"version": "4.2.8",
|
||||
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
|
||||
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w=="
|
||||
},
|
||||
"es6-promisify": {
|
||||
"version": "5.0.0",
|
||||
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
|
||||
"integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=",
|
||||
"requires": {
|
||||
"es6-promise": "^4.0.3"
|
||||
}
|
||||
},
|
||||
"express": {
|
||||
"version": "4.17.1",
|
||||
"requires": {
|
||||
"accepts": "~1.3.7",
|
||||
"array-flatten": "1.1.1",
|
||||
"body-parser": "1.19.0",
|
||||
"content-disposition": "0.5.3",
|
||||
"content-type": "~1.0.4",
|
||||
"cookie": "0.4.0",
|
||||
"cookie-signature": "1.0.6",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"encodeurl": "~1.0.2",
|
||||
"escape-html": "~1.0.3",
|
||||
"etag": "~1.8.1",
|
||||
"finalhandler": "~1.1.2",
|
||||
"fresh": "0.5.2",
|
||||
"merge-descriptors": "1.0.1",
|
||||
"methods": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
"parseurl": "~1.3.3",
|
||||
"path-to-regexp": "0.1.7",
|
||||
"proxy-addr": "~2.0.5",
|
||||
"qs": "6.7.0",
|
||||
"range-parser": "~1.2.1",
|
||||
"safe-buffer": "5.1.2",
|
||||
"send": "0.17.1",
|
||||
"serve-static": "1.14.1",
|
||||
"setprototypeof": "1.1.1",
|
||||
"statuses": "~1.5.0",
|
||||
"type-is": "~1.6.18",
|
||||
"utils-merge": "1.0.1",
|
||||
"vary": "~1.1.2"
|
||||
}
|
||||
},
|
||||
"https-proxy-agent": {
|
||||
"version": "2.2.4",
|
||||
"resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz",
|
||||
"integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==",
|
||||
"requires": {
|
||||
"agent-base": "^4.3.0",
|
||||
"debug": "^3.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": {
|
||||
"version": "3.2.6",
|
||||
"resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz",
|
||||
"integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==",
|
||||
"requires": {
|
||||
"ms": "^2.1.1"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.1.2",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
|
||||
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
|
||||
}
|
||||
}
|
||||
},
|
||||
"ip": {
|
||||
"version": "1.1.5",
|
||||
"resolved": "https://registry.npmjs.org/ip/-/ip-1.1.5.tgz",
|
||||
"integrity": "sha1-vd7XARQpCCjAoDnnLvJfWq7ENUo="
|
||||
},
|
||||
"mpp-client-xt": {
|
||||
"version": "1.2.0",
|
||||
"resolved": "https://registry.npmjs.org/mpp-client-xt/-/mpp-client-xt-1.2.0.tgz",
|
||||
"integrity": "sha512-r9xqbfX3kibfVXR2f5FYdEkeX5Ouh/UVGgEag9ofUMJQehK9oMpmc9aP4ZBH4W2Xh8fMqRb6EooEB4Pr/6ErAQ==",
|
||||
"requires": {
|
||||
"https-proxy-agent": "^2.2.1",
|
||||
"socks-proxy-agent": "^4.0.1",
|
||||
"ws": "^5.1.1"
|
||||
}
|
||||
},
|
||||
"smart-buffer": {
|
||||
"version": "4.1.0",
|
||||
"resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.1.0.tgz",
|
||||
"integrity": "sha512-iVICrxOzCynf/SNaBQCw34eM9jROU/s5rzIhpOvzhzuYHfJR/DhZfDkXiZSgKXfgv26HT3Yni3AV/DGw0cGnnw=="
|
||||
},
|
||||
"socks": {
|
||||
"version": "2.3.3",
|
||||
"resolved": "https://registry.npmjs.org/socks/-/socks-2.3.3.tgz",
|
||||
"integrity": "sha512-o5t52PCNtVdiOvzMry7wU4aOqYWL0PeCXRWBEiJow4/i/wr+wpsJQ9awEu1EonLIqsfGd5qSgDdxEOvCdmBEpA==",
|
||||
"requires": {
|
||||
"ip": "1.1.5",
|
||||
"smart-buffer": "^4.1.0"
|
||||
}
|
||||
},
|
||||
"socks-proxy-agent": {
|
||||
"version": "4.0.2",
|
||||
"resolved": "https://registry.npmjs.org/socks-proxy-agent/-/socks-proxy-agent-4.0.2.tgz",
|
||||
"integrity": "sha512-NT6syHhI9LmuEMSK6Kd2V7gNv5KFZoLE7V5udWmn0de+3Mkj3UMA/AJPLyeNUVmElCurSHtUdM3ETpR3z770Wg==",
|
||||
"requires": {
|
||||
"agent-base": "~4.2.1",
|
||||
"socks": "~2.3.2"
|
||||
},
|
||||
"dependencies": {
|
||||
"agent-base": {
|
||||
"version": "4.2.1",
|
||||
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.2.1.tgz",
|
||||
"integrity": "sha512-JVwXMr9nHYTUXsBFKUqhJwvlcYU/blreOEUkhNR2eXZIvwd+c+o5V4MgDPKWnMS/56awN3TRzIP+KoPn+roQtg==",
|
||||
"requires": {
|
||||
"es6-promisify": "^5.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"ws": {
|
||||
"version": "5.2.2",
|
||||
"resolved": "https://registry.npmjs.org/ws/-/ws-5.2.2.tgz",
|
||||
"integrity": "sha512-jaHFD6PFv6UgoIVda6qZllptQsMlDEJkTQcybzzXDYM1XO9Y8em691FGMPmM46WGyLU4z9KMgQN+qrux/nhlHA==",
|
||||
"requires": {
|
||||
"async-limiter": "~1.0.0"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -10,7 +10,8 @@
|
|||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"express": "^4.17.1"
|
||||
"express": "^4.17.1",
|
||||
"mpp-client-xt": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "12.x"
|
||||
|
@ -24,4 +25,4 @@
|
|||
"glitch",
|
||||
"express"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
86
server.js
86
server.js
|
@ -1,34 +1,70 @@
|
|||
// server.js
|
||||
// where your node app starts
|
||||
var http = require("http");
|
||||
|
||||
// we've started you off with Express (https://expressjs.com/)
|
||||
// but feel free to use whatever libraries or frameworks you'd like through `package.json`.
|
||||
const express = require("express");
|
||||
const app = express();
|
||||
http
|
||||
.createServer(function(request, response) {
|
||||
response.writeHead(200, { "Content-Type": "text/plain" });
|
||||
response.end(
|
||||
"welcome to hri's bot page :)\nthis is just here so heroku/glitch doesn't freak out"
|
||||
);
|
||||
})
|
||||
.listen(process.env.PORT || 3000);
|
||||
|
||||
// our default array of dreams
|
||||
const dreams = [
|
||||
"Find and count some sheep",
|
||||
"Climb a really tall mountain",
|
||||
"Wash the dishes"
|
||||
];
|
||||
console.log("HTTP Host Established");
|
||||
|
||||
// make all the files in 'public' available
|
||||
// https://expressjs.com/en/starter/static-files.html
|
||||
app.use(express.static("public"));
|
||||
const MPPClient = require('mpp-client-xt');
|
||||
const client = new MPPClient("http://www.multiplayerpiano.com", undefined);
|
||||
|
||||
// https://expressjs.com/en/starter/basic-routing.html
|
||||
app.get("/", (request, response) => {
|
||||
response.sendFile(__dirname + "/views/index.html");
|
||||
client.start();
|
||||
|
||||
client.on("hi", () => {
|
||||
client.sendArray([{m:'userset', set:{name:"dvdbot [dvd!help](by Hri7566)"}}]);
|
||||
client.setChannel("✧𝓡𝓟 𝓡𝓸𝓸𝓶✧");
|
||||
});
|
||||
|
||||
// send the default array of dreams to the webpage
|
||||
app.get("/dreams", (request, response) => {
|
||||
// express helps us take JS objects and send them as JSON
|
||||
response.json(dreams);
|
||||
function chat(string) {
|
||||
client.sendArray([{m:'a', message:string}]);
|
||||
}
|
||||
|
||||
var ctoggle = true;
|
||||
|
||||
client.on("a", (msg) => {
|
||||
let args = msg.a.split(' ');
|
||||
let cmd = args[0].toLowerCase();
|
||||
let argcat = msg.a.substring(cmd.length).trim();
|
||||
|
||||
switch (cmd) {
|
||||
case "dvd!help":
|
||||
chat("not finished :)");
|
||||
break;
|
||||
case "dvd!cursor"
|
||||
}
|
||||
});
|
||||
|
||||
// listen for requests :)
|
||||
const listener = app.listen(process.env.PORT, () => {
|
||||
console.log("Your app is listening on port " + listener.address().port);
|
||||
var pos = {x: -42, y: 5};
|
||||
var vel = {x: 2/5, y: 2/7};
|
||||
|
||||
var cursor = setInterval(function() {
|
||||
if (ctoggle == true) {
|
||||
client.sendArray([{m:'m', x: client.getOwnParticipant().x = pos.x + 50, y: client.getOwnParticipant().y = pos.y + 50}])
|
||||
} else {
|
||||
pos.x = 200;
|
||||
pos.y = 200;
|
||||
}
|
||||
});
|
||||
|
||||
var cursorupdate = setInterval(function() {
|
||||
pos.x += vel.x;
|
||||
pos.y += vel.y;
|
||||
if (pos.x >= 50) {
|
||||
vel.x = -vel.x;
|
||||
}
|
||||
if (pos.y >= 50) {
|
||||
vel.y = -vel.y;
|
||||
}
|
||||
if (pos.x <= -50) {
|
||||
vel.x = -vel.x;
|
||||
}
|
||||
if (pos.y <= -50) {
|
||||
vel.y = -vel.y;
|
||||
}
|
||||
}, 25);
|
Loading…
Reference in New Issue