implement pr bridge

guess it's good
This commit is contained in:
Lamp 2019-06-27 16:43:03 -07:00
parent 915efb7803
commit 66876def71
4 changed files with 123 additions and 59 deletions

98
package-lock.json generated
View File

@ -30,6 +30,11 @@
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz",
"integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c="
},
"base64-js": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.0.tgz",
"integrity": "sha512-ccav/yGvoa80BQDljCxsmmQ3Xvx60/UpBIij5QN21W3wBi/hhIC9OoO+KLpu9IJTS9j4DRVJ3aDDF9cMSoa2lw=="
},
"brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
@ -44,6 +49,15 @@
"resolved": "https://registry.npmjs.org/bson/-/bson-1.0.9.tgz",
"integrity": "sha512-IQX9/h7WdMBIW/q/++tGd+emQr0XMdeZ6icnT/74Xk9fnabWn+gZgpE+9V+gujL3hhJOoNrnDVY7tWdzc7NUTg=="
},
"buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-5.2.1.tgz",
"integrity": "sha512-c+Ko0loDaFfuPWiL02ls9Xd3GO3cPVmUobQ6t3rXNUk304u6hGq+8N/kFi+QEIKhzK3uwolVhLzszmfLmMLnqg==",
"requires": {
"base64-js": "^1.0.2",
"ieee754": "^1.1.4"
}
},
"buffer-from": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.0.tgz",
@ -54,6 +68,11 @@
"resolved": "https://registry.npmjs.org/buffer-writer/-/buffer-writer-1.0.1.tgz",
"integrity": "sha1-Iqk2kB4wKa/NdUfrRIfOtpejvwg="
},
"clone": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/clone/-/clone-2.1.1.tgz",
"integrity": "sha1-0hfR6WERjjrJpLi7oyhVU79kfNs="
},
"combined-stream": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.6.tgz",
@ -62,6 +81,11 @@
"delayed-stream": "~1.0.0"
}
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
@ -103,11 +127,14 @@
"form-data": "^2.3.2",
"node-fetch": "^2.1.2",
"pako": "^1.0.0",
"prism-media": "github:amishshah/prism-media#7146426e462bf91b39053de4cf8b78c72490cd54",
"tweetnacl": "^1.0.0",
"ws": "^6.0.0"
},
"dependencies": {
"prism-media": {
"version": "github:amishshah/prism-media#7146426e462bf91b39053de4cf8b78c72490cd54",
"from": "github:amishshah/prism-media#7146426e462bf91b39053de4cf8b78c72490cd54"
},
"ws": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-6.0.0.tgz",
@ -197,6 +224,11 @@
}
}
},
"ieee754": {
"version": "1.1.13",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.1.13.tgz",
"integrity": "sha512-4vf7I2LYV/HaWerSo3XmlMkp5eZ83i+/CDluXi/IGTs/O1sejBNhTtnxzmRZfvOUqj7lZjqHkeTvpgSFDlWZTg=="
},
"inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
@ -216,6 +248,11 @@
"resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz",
"integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE="
},
"linked-list": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/linked-list/-/linked-list-0.1.0.tgz",
"integrity": "sha1-eYsP+X0bkqT9CEgPVa6k6dSdN78="
},
"mime": {
"version": "1.6.0",
"resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz",
@ -384,10 +421,6 @@
"xtend": "^4.0.0"
}
},
"prism-media": {
"version": "github:amishshah/prism-media#7146426e462bf91b39053de4cf8b78c72490cd54",
"from": "github:amishshah/prism-media"
},
"process-nextick-args": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.0.tgz",
@ -418,6 +451,11 @@
"ws": "^3.0.0"
}
},
"querystring": {
"version": "0.2.0",
"resolved": "https://registry.npmjs.org/querystring/-/querystring-0.2.0.tgz",
"integrity": "sha1-sgmEkgO7Jd+CDadW50cAWHhSFiA="
},
"readable-stream": {
"version": "2.3.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz",
@ -465,11 +503,56 @@
"integrity": "sha512-5lvKUEQ7lAN5/vPl5d3k8FQeDbEamu9kizfATfLLWV5h6Mkh1xcieR1FSsJkcSRUk49lF2tAW8gzXWVwtwZVhw==",
"optional": true
},
"sc-channel": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/sc-channel/-/sc-channel-1.2.0.tgz",
"integrity": "sha512-M3gdq8PlKg0zWJSisWqAsMmTVxYRTpVRqw4CWAdKBgAfVKumFcTjoCV0hYu7lgUXccCtCD8Wk9VkkE+IXCxmZA==",
"requires": {
"component-emitter": "1.2.1"
}
},
"sc-errors": {
"version": "1.4.1",
"resolved": "https://registry.npmjs.org/sc-errors/-/sc-errors-1.4.1.tgz",
"integrity": "sha512-dBn92iIonpChTxYLgKkIT/PCApvmYT6EPIbRvbQKTgY6tbEbIy8XVUv4pGyKwEK4nCmvX4TKXcN0iXC6tNW6rQ=="
},
"sc-formatter": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/sc-formatter/-/sc-formatter-3.0.2.tgz",
"integrity": "sha512-9PbqYBpCq+OoEeRQ3QfFIGE6qwjjBcd2j7UjgDlhnZbtSnuGgHdcRklPKYGuYFH82V/dwd+AIpu8XvA1zqTd+A=="
},
"semver": {
"version": "5.5.0",
"resolved": "https://registry.npmjs.org/semver/-/semver-5.5.0.tgz",
"integrity": "sha512-4SJ3dm0WAwWy/NVeioZh5AntkdJoWKxHxcmyP622fOkgHa4z3R0TdBJICINyaSDE6uNwVc8gZr+ZinwZAH4xIA=="
},
"socketcluster-client": {
"version": "14.2.2",
"resolved": "https://registry.npmjs.org/socketcluster-client/-/socketcluster-client-14.2.2.tgz",
"integrity": "sha512-vofmFcTaHaIf+MqAR0OZS7e30X4jxbDPJl+taCe8kLGJ5rVOrKeuU0sGyHyHyqW87AIR6jqc4KODl4WQJ4SsAA==",
"requires": {
"buffer": "^5.2.1",
"clone": "2.1.1",
"component-emitter": "1.2.1",
"linked-list": "0.1.0",
"querystring": "0.2.0",
"sc-channel": "^1.2.0",
"sc-errors": "^1.4.1",
"sc-formatter": "^3.0.1",
"uuid": "3.2.1",
"ws": "5.1.1"
},
"dependencies": {
"ws": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/ws/-/ws-5.1.1.tgz",
"integrity": "sha512-bOusvpCb09TOBLbpMKszd45WKC2KPtxiyiHanv+H2DE3Az+1db5a/L7sVJZVDPUC1Br8f0SKRr1KjLpD1U/IAw==",
"requires": {
"async-limiter": "~1.0.0"
}
}
}
},
"split": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/split/-/split-1.0.1.tgz",
@ -511,6 +594,11 @@
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
},
"uuid": {
"version": "3.2.1",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-3.2.1.tgz",
"integrity": "sha512-jZnMwlb9Iku/O3smGWvZhauCf6cvvpKi4BKRiliS3cxnI+Gz9j5MEpTz2UFuXiKPJocb7gnsLHwiS05ige5BEA=="
},
"wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",

View File

@ -5,6 +5,7 @@
"mongodb": "^3.0.0-rc0",
"pg": "^7.4.0",
"puppeteer": "^0.13.0",
"socketcluster-client": "^14.2.2",
"ws": "^3.3.2"
}
}

View File

@ -1,7 +1,5 @@
const socketCluster = require("socketcluster-client")
const EventEmitter = require("events").EventEmitter;
const HttpsProxyAgent = require("https-proxy-agent");
const SocksProxyAgent = require("socks-proxy-agent");
class PRClient extends EventEmitter {
constructor(credentials, options) {
super()

View File

@ -1,28 +1,23 @@
const PRClient = require("./PRClient.js");
evalcmd();
const Discord = require("discord.js");
const dclient = new Discord.Client();
dclient.login("no u");
dclient.on('ready', () => {
let client = new PRClient({// account stuff
username: "Discord",
password: "vWmnsEkgAPcU3VR",
roomName: 'lobby'
});
client.connect();
client.socket.on("setRoom", function (data, callback) {
client.roomID = data.roomID;
try {
if (client.channels.chatChannel && client.roomID) {
client.socket.destroyChannel(client.roomID);
}
} catch (err) {}
client.channels.chatChannel = client.socket.subscribe(data.roomID);
client.channels.chatChannel.watch(messagehandle);
})
let client = new PRClient({// account stuff
username: "Discord",
password: "vWmnsEkgAPcU3VR",
roomName: 'lobby'
});
dClient.once("ready", () => client.connect());
client.socket.on("setRoom", function (data, callback) {
client.roomID = data.roomID;
try {
if (client.channels.chatChannel && client.roomID) {
client.socket.destroyChannel(client.roomID);
}
} catch (err) {}
client.channels.chatChannel = client.socket.subscribe(data.roomID);
client.channels.chatChannel.watch(messagehandle);
})
function messagehandle(data) {
async function messagehandle(data) {
if (data && data.type) {
switch (data.type) {
case "chat":
@ -32,40 +27,22 @@ function messagehandle(data) {
let roomName = data.roomName;
let color = data.color;
let id = data.id;
if (data.notify)
console.log("NOTIFY: " + data.message);
console.log(`${name}: ${data.message}`);
dclient.channels.get("380431177812803584").send(`${name}: ${data.message}`);
if (id == "[discord.gg/k44Eqha]") return;
dClient.channels.get("593943518351982603").send(`**${sanitizeName(name)}:** ${escapeDiscordMentions(data.message)}`);
}
break;
}
}
}
function evalcmd() {
//with all optional parameters set to opposite of default
const {
EntoliPrompt
} = require('entoli');
let EP = new EntoliPrompt('', {
enterMessage: false,
exitMessage: false,
preventExit: false
dClient.on("local_message", async message => {
client.socket.publish("fcf6e7e5-1d9a-48ee-808f-a9b626ce090b", {
"type": "chat",
"message": `${message.member.displayName}#${message.author.discriminator}: ${message.cleanContent + (message.attachments.size > 0 && message.attachments.map(x => x.url).join(' ') || '')}`,
"value": false,
"socketID": "[discord.gg/k44Eqha]",
"uuid": "[discord.gg/k44Eqha]",
"color": "#8012ed",
"name": "[discord.gg/k44Eqha]"
});
EP().then((a) => {
client.socket.publish("fcf6e7e5-1d9a-48ee-808f-a9b626ce090b", {
"type": "chat",
"message": a.toString(),
"value": false,
"socketID": "󠀀[discord.gg/k44Eqha]",
"uuid": "󠀀[discord.gg/k44Eqha]",
"color": "#8012ed",
"name": "󠀀[discord.gg/k44Eqha]"
})
evalcmd();
}).catch((e) => {
console.error(e);
evalcmd();
});
}
});