diff --git a/.gitignore b/.gitignore
index d71c927..b0640bc 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,3 +6,5 @@ googleapi\.json
setup.json
merged.mp3
output.mp3
+privkey.pem
+cert.pem
diff --git a/package-lock.json b/package-lock.json
index 1b70928..c113805 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -401,6 +401,17 @@
"snekfetch": "^3.6.4",
"tweetnacl": "^1.0.0",
"ws": "^4.0.0"
+ },
+ "dependencies": {
+ "ws": {
+ "version": "4.1.0",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
+ "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
+ "requires": {
+ "async-limiter": "~1.0.0",
+ "safe-buffer": "~5.1.0"
+ }
+ }
}
},
"duplexify": {
@@ -505,6 +516,11 @@
"escape-string-regexp": "^1.0.5"
}
},
+ "flatted": {
+ "version": "2.0.0",
+ "resolved": "https://registry.npmjs.org/flatted/-/flatted-2.0.0.tgz",
+ "integrity": "sha512-R+H8IZclI8AAkSBRQJLVOsxwAoHd6WC40b4QTNWIjzAa6BXOBfQcM587MXDTVPeYaopFNWHUFLx7eNmHDSxMWg=="
+ },
"fluent-ffmpeg": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/fluent-ffmpeg/-/fluent-ffmpeg-2.1.2.tgz",
@@ -1831,12 +1847,11 @@
"integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8="
},
"ws": {
- "version": "4.1.0",
- "resolved": "https://registry.npmjs.org/ws/-/ws-4.1.0.tgz",
- "integrity": "sha512-ZGh/8kF9rrRNffkLFV4AzhvooEclrOH0xaugmqGsIfFgOE/pIz4fMc4Ef+5HSQqTEug2S9JZIWDR47duDSLfaA==",
+ "version": "6.2.1",
+ "resolved": "https://registry.npmjs.org/ws/-/ws-6.2.1.tgz",
+ "integrity": "sha512-GIyAXC2cB7LjvpgMt9EKS2ldqr0MTrORaleiOno6TweZ6r3TKtoFQWay/2PceJ3RuBasOHzXNn5Lrw1X0bEjqA==",
"requires": {
- "async-limiter": "~1.0.0",
- "safe-buffer": "~5.1.0"
+ "async-limiter": "~1.0.0"
}
},
"xtend": {
diff --git a/package.json b/package.json
index 14b5bbf..9e64ed0 100644
--- a/package.json
+++ b/package.json
@@ -8,6 +8,7 @@
"@google-cloud/vision": "^0.25.0",
"colors": "^1.3.3",
"discord.js": "^11.4.2",
+ "flatted": "^2.0.0",
"fluent-ffmpeg": "^2.1.2",
"inquirer": "^6.2.2",
"mysql": "^2.16.0",
@@ -15,7 +16,8 @@
"ping": "^0.2.2",
"promise-mysql": "^3.3.1",
"readline": "^1.3.0",
- "request": "^2.88.0"
+ "request": "^2.88.0",
+ "ws": "^6.2.1"
},
"devDependencies": {},
"scripts": {
diff --git a/plugins/autovoicechannel.js b/plugins/autovoicechannel.js
index bfcb551..2393d7d 100644
--- a/plugins/autovoicechannel.js
+++ b/plugins/autovoicechannel.js
@@ -21,9 +21,7 @@ module.exports = {
.then(chan => {
chan.setParent(autoparent)
chan.setTopic(cid)
- chan.send(newMember + " **Hey**, this is the Text channel for your voice chat.\r\n **IT WILL BE DELETED ONCE EVERYONE LEAVES**")
- chan.send("If you would like to **share screens** or use your **webcam**: ****")
- chan.send("*⁽ᵗʰᶦˢ ᶠᵉᵃᵗᵘʳᵉ ᶦˢ ᵒⁿˡʸ ᵃᵛᵃᶦˡᵃᵇˡᵉ ᶦᶠ ʸᵒᵘ'ʳᵉ ᶦⁿ ᵗʰᵉ ᶜʰᵃᵗ⁾*")
+ chan.send(newMember + " **Hey**, this is the Text channel for your voice chat.\r\n **IT WILL BE DELETED ONCE EVERYONE LEAVES**\nIf you would like to **share screens** or use your **webcam**: ****\n*⁽ᵗʰᶦˢ ᶠᵉᵃᵗᵘʳᵉ ᶦˢ ᵒⁿˡʸ ᵃᵛᵃᶦˡᵃᵇˡᵉ ᶦᶠ ʸᵒᵘ'ʳᵉ ᶦⁿ ᵗʰᵉ ᶜʰᵃᵗ⁾*")
//chan.send("https://gfycat.com/RadiantFoolishAmmonite")
console.log("Made a Auto Channel Set: " + newMember.presence.game.name + " - " + newMember.displayName)
@@ -45,9 +43,7 @@ module.exports = {
.then(chan => {
chan.setParent(autoparent)
chan.setTopic(cid)
- chan.send(newMember + " **Hey**, this is the Text channel for your voice chat.\r\n **IT WILL BE DELETED ONCE EVERYONE LEAVES**")
- chan.send("\\***NEW**\\* If you would like to **share screens** or use your **webcam**: ****")
- chan.send("*⁽ᵗʰᶦˢ ᶠᵉᵃᵗᵘʳᵉ ᶦˢ ᵒⁿˡʸ ᵃᵛᵃᶦˡᵃᵇˡᵉ ᶦᶠ ʸᵒᵘ'ʳᵉ ᶦⁿ ᵗʰᵉ ᶜʰᵃᵗ⁾*")
+ chan.send(newMember + " **Hey**, this is the Text channel for your voice chat.\r\n **IT WILL BE DELETED ONCE EVERYONE LEAVES**\nIf you would like to **share screens** or use your **webcam**: ****\n*⁽ᵗʰᶦˢ ᶠᵉᵃᵗᵘʳᵉ ᶦˢ ᵒⁿˡʸ ᵃᵛᵃᶦˡᵃᵇˡᵉ ᶦᶠ ʸᵒᵘ'ʳᵉ ᶦⁿ ᵗʰᵉ ᶜʰᵃᵗ⁾*")
// chan.send("https://gfycat.com/RadiantFoolishAmmonite")
console.log("Made a Auto Channel Set: General - " + newMember.displayName)
diff --git a/plugins/wss.js b/plugins/wss.js
new file mode 100644
index 0000000..b004a5b
--- /dev/null
+++ b/plugins/wss.js
@@ -0,0 +1,64 @@
+const fs = require('fs');
+const https = require('https');
+const WebSocket = require('ws');
+const { parse, stringify } = require('flatted/cjs');
+
+module.exports = {
+ name: "Websockets Server (8080)",
+ init: (dclient) => {
+ const server = https.createServer({
+ cert: fs.readFileSync('./cert.pem'),
+ key: fs.readFileSync('./privkey.pem')
+ });
+ const wss = new WebSocket.Server({ server });
+
+ wss.on('connection', function connection(ws) {
+ ws.on('message', function incoming(message) {
+ console.log('received: %s', message);
+
+ try {
+ var data = parse(message)
+
+ var response = {
+ type: "data",
+ data: new Array()
+ }
+
+ if (data.type == "request") {
+ for (var i = 0; i < data.requests.length; i++) {
+ var resp = ""
+ if (data.requests[i] == "name")
+ resp = dclient.user.username
+ if (data.requests[i] == "id")
+ resp = dclient.user.id
+ if (data.requests[i] == "discriminator")
+ resp = dclient.user.discriminator
+ if (data.requests[i] == "avatar")
+ resp = dclient.user.avatarURL
+ response.data.push({ type: data.requests[i], data: resp })
+ }
+
+ ws.send(JSON.stringify(response))
+ }
+ }
+ catch (error) {
+ console.log(error)
+ }
+
+ });
+ ws.send('Connected');
+ });
+
+ setInterval(() => { //heartbeat
+ wss.clients.forEach(client => {
+ if (client.readyState == client.OPEN) {
+ client.send(JSON.stringify({ type: "heartbeat", time: new Date().getTime() }))
+ client.ping()
+ }
+ });
+ }, 30000);
+
+ server.listen(8080);
+
+ }
+}
\ No newline at end of file