stuff
This commit is contained in:
parent
8e97f373d0
commit
1849d86a63
|
@ -1,149 +0,0 @@
|
||||||
{
|
|
||||||
"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,24 +1,19 @@
|
||||||
{
|
{
|
||||||
"//1": "describes your app and its dependencies",
|
"name": "dvdbot",
|
||||||
"//2": "https://docs.npmjs.com/files/package.json",
|
"version": "1.0.0",
|
||||||
"//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.",
|
"description": "A simple Node app built on Express, instantly up and running.",
|
||||||
"main": "server.js",
|
"main": "server.js",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"start": "node server.js"
|
"start": "node server.js"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"express": "^4.17.1",
|
"dotenv": "^16.4.5",
|
||||||
"mpp-client-xt": "^1.2.0"
|
"express": "^4.19.2",
|
||||||
|
"mpp-client-net": "^1.2.1"
|
||||||
},
|
},
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": "12.x"
|
"node": "12.x"
|
||||||
},
|
},
|
||||||
"repository": {
|
|
||||||
"url": "https://glitch.com/edit/#!/hello-express"
|
|
||||||
},
|
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"node",
|
"node",
|
||||||
|
|
85
server.js
85
server.js
|
@ -1,31 +1,38 @@
|
||||||
const MPPClient = require('mpp-client-xt');
|
import { Client } from "mpp-client-net/src/index";
|
||||||
const client = new MPPClient("wss://mpp.hri7566.info:8443", undefined);
|
import { configDotenv } from "dotenv";
|
||||||
const fs = require('fs');
|
import fs from "fs";
|
||||||
|
|
||||||
|
console.log(Client);
|
||||||
|
|
||||||
|
configDotenv();
|
||||||
|
|
||||||
|
const client = new Client("wss://mppclone.com:8443", process.env.MPPNET_TOKEN);
|
||||||
|
|
||||||
client.start();
|
client.start();
|
||||||
|
|
||||||
client.on("hi", () => {
|
client.on("hi", () => {
|
||||||
setTimeout(function() {
|
setTimeout(function () {
|
||||||
client.sendArray([{m:'userset', set:{name:"hri's dvdbot [dvd!help]"}}]);
|
client.sendArray([
|
||||||
})
|
{ m: "userset", set: { name: "hri's dvdbot [dvd!help]" } },
|
||||||
|
]);
|
||||||
client.setChannel("lobby");
|
});
|
||||||
|
|
||||||
|
client.setChannel("test/awkward");
|
||||||
});
|
});
|
||||||
|
|
||||||
function chat(string) {
|
function chat(string) {
|
||||||
client.sendArray([{m:'a', message:string}]);
|
client.sendArray([{ m: "a", message: string }]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var ctoggle = true;
|
var ctoggle = true;
|
||||||
|
|
||||||
var cursormode = "dvd";
|
var cursormode = "dvd";
|
||||||
|
|
||||||
|
|
||||||
client.on("a", (msg) => {
|
client.on("a", (msg) => {
|
||||||
let args = msg.a.split(' ');
|
let args = msg.a.split(" ");
|
||||||
let cmd = args[0].toLowerCase();
|
let cmd = args[0].toLowerCase();
|
||||||
let argcat = msg.a.substring(cmd.length).trim();
|
let argcat = msg.a.substring(cmd.length).trim();
|
||||||
|
|
||||||
switch (cmd) {
|
switch (cmd) {
|
||||||
case "dvd!help":
|
case "dvd!help":
|
||||||
chat("cmds: dvd!help // dvd!cursor // dvd!stats // dvd!about");
|
chat("cmds: dvd!help // dvd!cursor // dvd!stats // dvd!about");
|
||||||
|
@ -37,14 +44,14 @@ client.on("a", (msg) => {
|
||||||
switch (argcat) {
|
switch (argcat) {
|
||||||
case "on":
|
case "on":
|
||||||
ctoggle = true;
|
ctoggle = true;
|
||||||
pos = {x: (Math.random() * 100) - 50, y: (Math.random() * 100) - 50};
|
pos = { x: Math.random() * 100 - 50, y: Math.random() * 100 - 50 };
|
||||||
vel = {x: 2/5, y: 2/7};
|
vel = { x: 2 / 5, y: 2 / 7 };
|
||||||
cursormode = "dvd";
|
cursormode = "dvd";
|
||||||
break;
|
break;
|
||||||
case "off":
|
case "off":
|
||||||
ctoggle = false;
|
ctoggle = false;
|
||||||
cursormode = "none";
|
cursormode = "none";
|
||||||
pos = {x: -500, y: -500};
|
pos = { x: -500, y: -500 };
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
chat("invalid :P");
|
chat("invalid :P");
|
||||||
|
@ -53,54 +60,62 @@ client.on("a", (msg) => {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "dvd!stats":
|
case "dvd!stats":
|
||||||
chat("Edge hits: " + stats.edgehits + " | Corner hits: " + stats.cornerhits);
|
chat(
|
||||||
|
"Edge hits: " + stats.edgehits + " | Corner hits: " + stats.cornerhits,
|
||||||
|
);
|
||||||
break;
|
break;
|
||||||
case "dvd!about":
|
case "dvd!about":
|
||||||
chat("Made by Hri7566 in his free time :)");
|
chat("this bot is ancient dude");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var pos = {x: (Math.random() * 100) - 50, y: (Math.random() * 100) - 50};
|
var pos = { x: Math.random() * 100 - 50, y: Math.random() * 100 - 50 };
|
||||||
var vel = {x: 2/5, y: 2/7};
|
var vel = { x: 2 / 5, y: 2 / 7 };
|
||||||
var statsraw = fs.readFileSync('stats.json');
|
var statsraw = fs.readFileSync("stats.json");
|
||||||
var stats = JSON.parse(statsraw);
|
var stats = JSON.parse(statsraw);
|
||||||
console.log(stats);
|
console.log(stats);
|
||||||
|
|
||||||
var cursor = setInterval(function() {
|
var cursor = setInterval(function () {
|
||||||
client.sendArray([{m:'m', x: client.getOwnParticipant().x = pos.x + 50, y: client.getOwnParticipant().y = pos.y + 50}]);
|
client.sendArray([
|
||||||
}, 16);
|
{
|
||||||
|
m: "m",
|
||||||
|
x: (client.getOwnParticipant().x = pos.x + 50),
|
||||||
|
y: (client.getOwnParticipant().y = pos.y + 50),
|
||||||
|
},
|
||||||
|
]);
|
||||||
|
}, 1000 / 20);
|
||||||
|
|
||||||
var cursorupdate = setInterval(function() {
|
var cursorupdate = setInterval(function () {
|
||||||
switch (cursormode) {
|
switch (cursormode) {
|
||||||
case "dvd":
|
case "dvd":
|
||||||
pos.x += vel.x;
|
pos.x += vel.x;
|
||||||
pos.y += vel.y;
|
pos.y += vel.y;
|
||||||
if (pos.x >= 50) {
|
if (pos.x >= 50) {
|
||||||
vel.x = -vel.x;
|
vel.x = -vel.x;
|
||||||
}
|
}
|
||||||
if (pos.y >= 50) {
|
if (pos.y >= 50) {
|
||||||
vel.y = -vel.y;
|
vel.y = -vel.y;
|
||||||
}
|
}
|
||||||
if (pos.x <= -50) {
|
if (pos.x <= -50) {
|
||||||
vel.x = -vel.x;
|
vel.x = -vel.x;
|
||||||
}
|
}
|
||||||
if (pos.y <= -50) {
|
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;
|
stats.cornerhits += 1;
|
||||||
} else if ((pos.x >= 50) && (pos.y <= -50)) {
|
} else if (pos.x >= 50 && pos.y <= -50) {
|
||||||
stats.cornerhits += 1;
|
stats.cornerhits += 1;
|
||||||
} else if ((pos.x <= -50) && (pos.y <= -50)) {
|
} else if (pos.x <= -50 && pos.y <= -50) {
|
||||||
stats.cornerhits += 1;
|
stats.cornerhits += 1;
|
||||||
} else if ((pos.x <= -50) && (pos.y >= 50)) {
|
} else if (pos.x <= -50 && pos.y >= 50) {
|
||||||
stats.cornerhits += 1;
|
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;
|
stats.edgehits += 1;
|
||||||
}
|
}
|
||||||
let statsjson = JSON.stringify(stats);
|
let statsjson = JSON.stringify(stats);
|
||||||
fs.writeFile("stats.json", statsjson, 'utf8', function (err) {
|
fs.writeFile("stats.json", statsjson, "utf8", function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
console.log("stats.json couldn't be saved!");
|
console.log("stats.json couldn't be saved!");
|
||||||
return console.log(err);
|
return console.log(err);
|
||||||
|
@ -108,4 +123,4 @@ var cursorupdate = setInterval(function() {
|
||||||
});
|
});
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}, 25);
|
}, 1000 / 30);
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
[]
|
{"edgehits":67,"cornerhits":0}
|
Loading…
Reference in New Issue