Compare commits
No commits in common. "1849d86a63f7a199f938737017d3982e91a88830" and "1d363616483047ef269d3d6a6ba5a60c20c99d1e" have entirely different histories.
1849d86a63
...
1d36361648
|
@ -1,2 +0,0 @@
|
|||
node_modules
|
||||
.env
|
31
README.md
31
README.md
|
@ -1,3 +1,30 @@
|
|||
# dvdbot-hri7566
|
||||
# hello-express
|
||||
|
||||
DVD bot from March 2020
|
||||
A server that serves a webpage, its resources, and some data
|
||||
|
||||
|
||||
## Your Project
|
||||
|
||||
On the front-end,
|
||||
|
||||
- Edit `views/index.html` to change the content of the webpage
|
||||
- `public/client.js` is the javacript that runs when you load the webpage
|
||||
- `public/style.css` is the styles for `views/index.html`
|
||||
- Drag in `assets`, like images or music, to add them to your project
|
||||
|
||||
On the back-end,
|
||||
|
||||
- your app starts at `server.js`
|
||||
- add frameworks and packages in `package.json`
|
||||
- safely store app secrets in `.env` (nobody can see this but you and people you invite)
|
||||
|
||||
Click `Show` in the header to see your app live. Updates to your code will instantly deploy.
|
||||
|
||||
|
||||
## Made by [Glitch](https://glitch.com/)
|
||||
|
||||
**Glitch** is the friendly community where you'll build the app of your dreams. Glitch lets you instantly create, remix, edit, and host an app, bot or site, and you can invite collaborators or helpers to simultaneously edit code with you.
|
||||
|
||||
Find out more [about Glitch](https://glitch.com/about).
|
||||
|
||||
( ᵔ ᴥ ᵔ )
|
|
@ -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"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
15
package.json
|
@ -1,19 +1,24 @@
|
|||
{
|
||||
"name": "dvdbot",
|
||||
"version": "1.0.0",
|
||||
"//1": "describes your app and its dependencies",
|
||||
"//2": "https://docs.npmjs.com/files/package.json",
|
||||
"//3": "updating this file will download and update your packages",
|
||||
"name": "hello-express",
|
||||
"version": "0.0.1",
|
||||
"description": "A simple Node app built on Express, instantly up and running.",
|
||||
"main": "server.js",
|
||||
"scripts": {
|
||||
"start": "node server.js"
|
||||
},
|
||||
"dependencies": {
|
||||
"dotenv": "^16.4.5",
|
||||
"express": "^4.19.2",
|
||||
"mpp-client-net": "^1.2.1"
|
||||
"express": "^4.17.1",
|
||||
"mpp-client-xt": "^1.2.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": "12.x"
|
||||
},
|
||||
"repository": {
|
||||
"url": "https://glitch.com/edit/#!/hello-express"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"node",
|
||||
|
|
85
server.js
85
server.js
|
@ -1,38 +1,31 @@
|
|||
import { Client } from "mpp-client-net/src/index";
|
||||
import { configDotenv } from "dotenv";
|
||||
import fs from "fs";
|
||||
|
||||
console.log(Client);
|
||||
|
||||
configDotenv();
|
||||
|
||||
const client = new Client("wss://mppclone.com:8443", process.env.MPPNET_TOKEN);
|
||||
const MPPClient = require('mpp-client-xt');
|
||||
const client = new MPPClient("wss://ts.terrium.net:8443", undefined);
|
||||
const fs = require('fs');
|
||||
|
||||
client.start();
|
||||
|
||||
client.on("hi", () => {
|
||||
setTimeout(function () {
|
||||
client.sendArray([
|
||||
{ m: "userset", set: { name: "hri's dvdbot [dvd!help]" } },
|
||||
]);
|
||||
});
|
||||
|
||||
client.setChannel("test/awkward");
|
||||
setTimeout(function() {
|
||||
client.sendArray([{m:'userset', set:{name:"hri's dvdbot [dvd!help]"}}]);
|
||||
})
|
||||
|
||||
client.setChannel("lobby");
|
||||
});
|
||||
|
||||
function chat(string) {
|
||||
client.sendArray([{ m: "a", message: string }]);
|
||||
client.sendArray([{m:'a', message:string}]);
|
||||
}
|
||||
|
||||
var ctoggle = true;
|
||||
|
||||
var cursormode = "dvd";
|
||||
|
||||
|
||||
client.on("a", (msg) => {
|
||||
let args = msg.a.split(" ");
|
||||
let args = msg.a.split(' ');
|
||||
let cmd = args[0].toLowerCase();
|
||||
let argcat = msg.a.substring(cmd.length).trim();
|
||||
|
||||
|
||||
switch (cmd) {
|
||||
case "dvd!help":
|
||||
chat("cmds: dvd!help // dvd!cursor // dvd!stats // dvd!about");
|
||||
|
@ -44,14 +37,14 @@ client.on("a", (msg) => {
|
|||
switch (argcat) {
|
||||
case "on":
|
||||
ctoggle = true;
|
||||
pos = { x: Math.random() * 100 - 50, y: Math.random() * 100 - 50 };
|
||||
vel = { x: 2 / 5, y: 2 / 7 };
|
||||
pos = {x: (Math.random() * 100) - 50, y: (Math.random() * 100) - 50};
|
||||
vel = {x: 2/5, y: 2/7};
|
||||
cursormode = "dvd";
|
||||
break;
|
||||
case "off":
|
||||
ctoggle = false;
|
||||
cursormode = "none";
|
||||
pos = { x: -500, y: -500 };
|
||||
pos = {x: -500, y: -500};
|
||||
break;
|
||||
default:
|
||||
chat("invalid :P");
|
||||
|
@ -60,62 +53,54 @@ client.on("a", (msg) => {
|
|||
}
|
||||
break;
|
||||
case "dvd!stats":
|
||||
chat(
|
||||
"Edge hits: " + stats.edgehits + " | Corner hits: " + stats.cornerhits,
|
||||
);
|
||||
chat("Edge hits: " + stats.edgehits + " | Corner hits: " + stats.cornerhits);
|
||||
break;
|
||||
case "dvd!about":
|
||||
chat("this bot is ancient dude");
|
||||
chat("Made by Hri7566 in his free time :)");
|
||||
break;
|
||||
}
|
||||
});
|
||||
|
||||
var pos = { x: Math.random() * 100 - 50, y: Math.random() * 100 - 50 };
|
||||
var vel = { x: 2 / 5, y: 2 / 7 };
|
||||
var statsraw = fs.readFileSync("stats.json");
|
||||
var pos = {x: (Math.random() * 100) - 50, y: (Math.random() * 100) - 50};
|
||||
var vel = {x: 2/5, y: 2/7};
|
||||
var statsraw = fs.readFileSync('stats.json');
|
||||
var stats = JSON.parse(statsraw);
|
||||
console.log(stats);
|
||||
|
||||
var cursor = setInterval(function () {
|
||||
client.sendArray([
|
||||
{
|
||||
m: "m",
|
||||
x: (client.getOwnParticipant().x = pos.x + 50),
|
||||
y: (client.getOwnParticipant().y = pos.y + 50),
|
||||
},
|
||||
]);
|
||||
}, 1000 / 20);
|
||||
var cursor = setInterval(function() {
|
||||
client.sendArray([{m:'m', x: client.getOwnParticipant().x = pos.x + 50, y: client.getOwnParticipant().y = pos.y + 50}]);
|
||||
}, 16);
|
||||
|
||||
var cursorupdate = setInterval(function () {
|
||||
var cursorupdate = setInterval(function() {
|
||||
switch (cursormode) {
|
||||
case "dvd":
|
||||
pos.x += vel.x;
|
||||
pos.y += vel.y;
|
||||
if (pos.x >= 50) {
|
||||
vel.x = -vel.x;
|
||||
vel.x = -vel.x;
|
||||
}
|
||||
if (pos.y >= 50) {
|
||||
vel.y = -vel.y;
|
||||
vel.y = -vel.y;
|
||||
}
|
||||
if (pos.x <= -50) {
|
||||
vel.x = -vel.x;
|
||||
vel.x = -vel.x;
|
||||
}
|
||||
if (pos.y <= -50) {
|
||||
vel.y = -vel.y;
|
||||
vel.y = -vel.y;
|
||||
}
|
||||
if (pos.x >= 50 && pos.y >= 50) {
|
||||
if ((pos.x >= 50) && (pos.y >= 50)) {
|
||||
stats.cornerhits += 1;
|
||||
} else if (pos.x >= 50 && pos.y <= -50) {
|
||||
} else if ((pos.x >= 50) && (pos.y <= -50)) {
|
||||
stats.cornerhits += 1;
|
||||
} else if (pos.x <= -50 && pos.y <= -50) {
|
||||
} else if ((pos.x <= -50) && (pos.y <= -50)) {
|
||||
stats.cornerhits += 1;
|
||||
} else if (pos.x <= -50 && pos.y >= 50) {
|
||||
} else if ((pos.x <= -50) && (pos.y >= 50)) {
|
||||
stats.cornerhits += 1;
|
||||
} else if (pos.x >= 50 || pos.y >= 50 || pos.y <= -50 || pos.x <= -50) {
|
||||
} else if ((pos.x >= 50) || (pos.y >= 50) || (pos.y <= -50) || (pos.x <= -50)) {
|
||||
stats.edgehits += 1;
|
||||
}
|
||||
let statsjson = JSON.stringify(stats);
|
||||
fs.writeFile("stats.json", statsjson, "utf8", function (err) {
|
||||
fs.writeFile("stats.json", statsjson, 'utf8', function (err) {
|
||||
if (err) {
|
||||
console.log("stats.json couldn't be saved!");
|
||||
return console.log(err);
|
||||
|
@ -123,4 +108,4 @@ var cursorupdate = setInterval(function () {
|
|||
});
|
||||
break;
|
||||
}
|
||||
}, 1000 / 30);
|
||||
}, 25);
|
||||
|
|
|
@ -1 +1 @@
|
|||
{"edgehits":67,"cornerhits":0}
|
||||
{"edgehits":23321,"cornerhits":39}
|
Loading…
Reference in New Issue