Compare commits
34 Commits
7fe2b0fa12
..
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0121a48063 | |||
| 525346ddcf | |||
| dff251d33d | |||
| 7e64c4379e | |||
| f3f8a35107 | |||
| 39adc796d0 | |||
| 5ac9604504 | |||
| 2527a331a7 | |||
| 17052a9ffe | |||
| e0dea9ebf4 | |||
| 4a40060439 | |||
| b507813f0a | |||
| 5476ecf714 | |||
| ef4ccb8bc0 | |||
| 995ac6d96f | |||
| e21a264ed0 | |||
| 1af74e957d | |||
| 8bfd16a41f | |||
| a86466efdb | |||
| 999e71c5cc | |||
| 6b29918703 | |||
| 41a1f0533f | |||
| 48b7791ae3 | |||
| fe0c0bbe61 | |||
| 7b934bf762 | |||
| 44cd2cabb4 | |||
| 9775aef89a | |||
| aabebc7d74 | |||
| 1fda5903d0 | |||
| 35d1299897 | |||
| fa1c39790a | |||
| 14c8c8fba3 | |||
| 198a8ceb3a | |||
| e8b4334e3a |
+10
-10
@@ -1,13 +1,13 @@
|
||||
[
|
||||
{ "room": "lobby", "channel": "339609383644168195", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "lobby2", "channel": "350006891948277770", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧", "channel": "698736467559710740", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "test/awkward", "channel": "360556775860076544", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "test/fishing", "channel": "339613702472859659", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "the-dev-channel", "channel": "925129849457233970", "uri": "wss://mppclone.com:8443" },
|
||||
{ "room": "lobby", "channel": "1159943041692471488", "uri": "wss://game.multiplayerpiano.com:443" },
|
||||
{ "room": "lobby2", "channel": "1159954805146529823", "uri": "wss://game.multiplayerpiano.com:443" },
|
||||
{ "room": "test/awkward", "channel": "1159954847542546513", "uri": "wss://game.multiplayerpiano.com:443" },
|
||||
|
||||
{ "room": "lobby", "channel": "430226348901007360", "uri": "wss://mppws.cf" },
|
||||
{ "room": "lobby", "channel": "339904195719200768", "uri": "wss://piano.ourworldofpixels.com" },
|
||||
{ "room": "lobby", "channel": "559898407511261219", "uri": "ws://104.237.150.24:8513/" },
|
||||
{ "room": "lobby", "channel": "927720571201028187", "uri": "wss://beta-mpp.cedms.jp" }
|
||||
{ "room": "lobby", "channel": "339609383644168195", "uri": "wss://backend.multiplayerpiano.net" },
|
||||
{ "room": "lobby2", "channel": "350006891948277770", "uri": "wss://backend.multiplayerpiano.net" },
|
||||
{ "room": "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧", "channel": "698736467559710740", "uri": "wss://backend.multiplayerpiano.net" },
|
||||
{ "room": "test/awkward", "channel": "360556775860076544", "uri": "wss://backend.multiplayerpiano.net" },
|
||||
{ "room": "test/fishing", "channel": "339613702472859659", "uri": "wss://backend.multiplayerpiano.net" },
|
||||
|
||||
{ "room": "lobby", "channel": "339904195719200768", "uri": "wss://piano.ourworldofpixels.com" }
|
||||
]
|
||||
+3
-3
@@ -12,10 +12,10 @@ global.commands = [
|
||||
];
|
||||
|
||||
|
||||
client.on("interactionCreate", interaction => {
|
||||
dClient.on("interactionCreate", interaction => {
|
||||
commands.find(x => x.name == interaction.commandName)?.exec?.(interaction);
|
||||
});
|
||||
|
||||
client.once("ready", () => {
|
||||
client.guilds.resolve(config.guildID)?.commands.set(commands);
|
||||
dClient.once("ready", () => {
|
||||
dClient.guilds.resolve(config.guildID)?.commands.set(commands);
|
||||
});
|
||||
@@ -11,7 +11,7 @@ module.exports = {
|
||||
"pinboard": process.env.WEBHOOK_PINBOARD
|
||||
},
|
||||
|
||||
"opID": "707359017252683896",
|
||||
"opID": "330499035419115522",
|
||||
"guildID": testmode ? "467473467634089985" : "321819041348190249",
|
||||
|
||||
"channels": { // includes voice channels & category channels
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
var os = require('os');
|
||||
var zlib = require('zlib');
|
||||
|
||||
// WebSocket message data collector. Returns a function for inputting websocket messages.
|
||||
// Collects inputted messages to a file and gzips them every time it reaches 8mb,
|
||||
// and sends it to the output callback function.
|
||||
// For recording websocket data to a discord channel.
|
||||
module.exports = function createWSMessageCollector(output) { // output func must be async
|
||||
var filepath = os.tmpdir() + "/" + Math.random().toString(36).substring(2);
|
||||
var size = 0;
|
||||
var startDate = new Date();
|
||||
|
||||
// gzip the data & send to output callback
|
||||
async function save(callback){
|
||||
fs.readFile(filepath, (err, file) => {
|
||||
if (err) return handleError(err);
|
||||
zlib.gzip(file, async function(err, data){
|
||||
if (err) return handleError(err);
|
||||
var thisStartDate = startDate, thisEndDate = new Date();
|
||||
fs.writeFileSync(filepath, '');
|
||||
size = 0;
|
||||
startDate = new Date();
|
||||
await output(data, thisStartDate, thisEndDate);
|
||||
if (callback) callback();
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// save on exit
|
||||
exitHook(callback => {
|
||||
save(()=>callback());
|
||||
});
|
||||
|
||||
return function input(message) { // input for websocket messages
|
||||
message = message.data || message;
|
||||
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString('base64');
|
||||
var line = `${Date.now()} ${message}\n`;
|
||||
size += line.length;
|
||||
fs.appendFileSync(filepath, line);
|
||||
if (size > 8000000) {save(); size = 0;}
|
||||
};
|
||||
}
|
||||
+4
-4
@@ -1,14 +1,14 @@
|
||||
var WebSocket = require('ws');
|
||||
var Discord = require('discord.js');
|
||||
var createWsMessageCollector = require('./datacollector');
|
||||
var WebSocketMessageCollector = require('./lib/datacollector');
|
||||
|
||||
var webhook = new Discord.WebhookClient({url: config.webhooks.ddp, allowedMentions: {parse: []}});
|
||||
var webhook = new Discord.WebhookClient({url: config.webhooks.ddp}, {allowedMentions: {parse: []}});
|
||||
|
||||
var ws;
|
||||
var wasConnected = false;
|
||||
//var myId;
|
||||
|
||||
var collectWsMessage = createWsMessageCollector(async function(data, startDate, endDate){
|
||||
var wsc = new WebSocketMessageCollector(async function(data, startDate, endDate){
|
||||
await webhook.send({files:[{
|
||||
attachment: data,
|
||||
name: `daydun piano main raw data recording from ${startDate.toISOString()} to ${endDate.toISOString()} .txt.gz`
|
||||
@@ -22,7 +22,7 @@ var collectWsMessage = createWsMessageCollector(async function(data, startDate,
|
||||
wasConnected = true;
|
||||
});
|
||||
ws.on("message", message => {
|
||||
collectWsMessage(message);
|
||||
wsc.collect(message);
|
||||
if (typeof message != 'string') return;
|
||||
var transmission = JSON.parse(message);
|
||||
if (transmission.type == 'chat') {
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
|
||||
client.on("messageCreate", async function (message) {
|
||||
dClient.on("messageCreate", async function (message) {
|
||||
if (message.author.id != config.opID) return;
|
||||
if (message.content.startsWith("!>")) {
|
||||
with (message) {
|
||||
|
||||
+7
-8
@@ -74,14 +74,13 @@ Client.prototype.connect = function() {
|
||||
return;
|
||||
this.emit("status", "Connecting...");
|
||||
if(typeof module !== "undefined") {
|
||||
let headers = {
|
||||
"origin": `https://${new URL(this.uri).host}`,
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/140.0.0.0 Safari/537.36"
|
||||
};
|
||||
if (this.uri.includes("multiplayerpiano.com")) headers["X-Forwarded-For"] = `${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}.${Math.floor(Math.random() * 256)}`;
|
||||
// nodejsicle
|
||||
require('https').get('https://app_legacy.multiplayerpiano.com').on("error", () => {});
|
||||
this.ws = new WebSocket(this.uri, {
|
||||
headers: {
|
||||
"origin": "https://multiplayerpiano.com",
|
||||
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36"
|
||||
}
|
||||
});
|
||||
this.ws = new WebSocket(this.uri, {headers});
|
||||
} else {
|
||||
// browseroni
|
||||
this.ws = new WebSocket(this.uri);
|
||||
@@ -106,7 +105,7 @@ Client.prototype.connect = function() {
|
||||
} else {
|
||||
++self.connectionAttempts;
|
||||
}
|
||||
var ms_lut = [50, 2950, 7000, 10000];
|
||||
var ms_lut = [50, 2950, 7000, 10000, 30000, 60000];
|
||||
var idx = self.connectionAttempts;
|
||||
if(idx >= ms_lut.length) idx = ms_lut.length - 1;
|
||||
var ms = ms_lut[idx];
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
module.exports = class DiscordMessageSender {
|
||||
constructor(channel) {
|
||||
this.channel = channel;
|
||||
this.interval = setInterval(this.flush.bind(this), 3000);
|
||||
}
|
||||
|
||||
//async init() {
|
||||
// var webhooks = await this.channel.fetchWebhooks();
|
||||
// this.webhook = webhooks.filter(w => w.token).first() || await this.channel.createWebhook("sdfadffg");
|
||||
// this.interval = setInterval(this.flush.bind(this), 3000);
|
||||
//}
|
||||
|
||||
|
||||
send(text) {
|
||||
this.pp ||= {content: ""};
|
||||
this.pp.content += text + '\n';
|
||||
}
|
||||
|
||||
sendEmbed(embed) {
|
||||
this.pp ||= {};
|
||||
this.pp.embeds = [embed];
|
||||
this.flush();
|
||||
}
|
||||
|
||||
flush() {
|
||||
if (!this.pp) return;
|
||||
var pp = this.pp;
|
||||
delete this.pp;
|
||||
if (pp.content?.length > 2000) {
|
||||
pp.files = [{name: "message.txt", attachment: Buffer.from(pp.content)}];
|
||||
delete pp.content;
|
||||
}
|
||||
//this.webhook.send(pp).catch(error => {
|
||||
//handleError(error, "webhook");
|
||||
this.channel.send(pp);
|
||||
//});
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
var gzip = require("util").promisify(require("zlib").gzip);
|
||||
|
||||
module.exports = class WebSocketMessageCollector {
|
||||
constructor(dispatchFunction) {
|
||||
this.maxSize = 8000000;
|
||||
this.data = "";
|
||||
this.startDate = new Date();
|
||||
this.dispatchFunction = dispatchFunction;
|
||||
exitHook(cb => {
|
||||
this.package().then(cb);
|
||||
});
|
||||
}
|
||||
|
||||
collect(message) {
|
||||
message = message.data || message;
|
||||
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString('base64');
|
||||
var line = `${Date.now()} ${message}\n`;
|
||||
this.data += line;
|
||||
if (this.data.length > this.maxSize) this.package();
|
||||
}
|
||||
|
||||
async package() {
|
||||
var data = this.data, startDate = this.startDate, endDate = new Date();
|
||||
this.data = "", this.startDate = new Date();
|
||||
data = await gzip(data);
|
||||
await this.dispatchFunction(data, startDate, endDate);
|
||||
}
|
||||
}
|
||||
@@ -13,12 +13,12 @@ global.dClient = new Discord.Client({
|
||||
|
||||
// error handling
|
||||
{
|
||||
let webhook = new Discord.WebhookClient({url: config.webhooks.error, allowedMentions: {parse: []}});
|
||||
let webhook = new Discord.WebhookClient({url: config.webhooks.error}, {allowedMentions: {parse: []}});
|
||||
global.handleError = function logError(error, title) {
|
||||
let msg = error && (error.stack || error.message || error);
|
||||
console.error(title + ':\n' + msg);
|
||||
try {
|
||||
webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
|
||||
//webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
|
||||
} catch(e) {}
|
||||
}
|
||||
process.on('unhandledRejection', error => handleError(error, "Unhandled Rejection"));
|
||||
@@ -39,4 +39,3 @@ require("./commands");
|
||||
require('./mppbridger');
|
||||
require('./misc');
|
||||
require('./ddpbridge');
|
||||
require('./prbridge');
|
||||
@@ -1,6 +1,6 @@
|
||||
// join/leave
|
||||
(async function(){
|
||||
var webhook = new Discord.WebhookClient({url: config.webhooks.welcome, allowedMentions: {parse: []}});
|
||||
var webhook = new Discord.WebhookClient({url: config.webhooks.welcome}, {allowedMentions: {parse: []}});
|
||||
dClient.on('guildMemberAdd', async member => {
|
||||
if (member.guild.id != config.guildID) return;
|
||||
let username = member.user.username.toLowerCase().includes('clyde') ? member.user.username.replace(/C/g,'Q').replace(/c/g,'q') : member.user.username;
|
||||
@@ -9,7 +9,7 @@
|
||||
dClient.on('guildMemberRemove', async member => {
|
||||
if (member.guild.id != config.guildID) return;
|
||||
let username = member.user.username.toLowerCase().includes('clyde') ? member.user.username.replace(/C/g,'Q').replace(/c/g,'q') : member.user.username;
|
||||
webhook.send({content: `${member.user.tag} left.`, username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
|
||||
webhook.send({content: `${member.user.username} left.`, username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
|
||||
});
|
||||
})();
|
||||
|
||||
@@ -67,17 +67,7 @@ dClient.on("emojiDelete", async emoji => {
|
||||
// allow anyone to pin a message via reaction
|
||||
// todo need enable partials for it to work on old messages
|
||||
dClient.on("messageReactionAdd", async (messageReaction) => {
|
||||
if (messageReaction.guild.id != config.guildID) return;
|
||||
if (messageReaction.guild?.id != config.guildID) return;
|
||||
if (messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")
|
||||
await messageReaction.message.pin();
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
+30
-46
@@ -1,32 +1,13 @@
|
||||
var Client = require('./lib/Client.js');
|
||||
var WebSocketMessageCollector = require("./lib/datacollector");
|
||||
var DiscordMessageSender = require("./lib/DiscordMessageSender");
|
||||
|
||||
global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
channel = dClient.channels.resolve(channel);
|
||||
var webhooks = await channel.fetchWebhooks();
|
||||
var webhook = webhooks.filter(w => w.token).first() || await channel.createWebhook("sdfadffg");
|
||||
|
||||
//todo figure out new way to buffer
|
||||
function dSend(msg, options = {}) {
|
||||
if (msg) options.content = msg;
|
||||
|
||||
if (options.content?.length > 2000) {
|
||||
options.attachments ||= [];
|
||||
options.attachments.push(new Discord.MessageAttachment(Buffer.from(options.content), "message.txt"));
|
||||
delete options.content;
|
||||
}
|
||||
|
||||
let username = gClient.channel && gClient.channel._id || room;
|
||||
if (username.length > 80) username = username.substr(0,79) + '…';
|
||||
|
||||
webhook.send(Object.assign(options, {username})).catch(error => {
|
||||
handleError(error, `webhook fail in ${channel.id}`);
|
||||
channel.send(options).catch(error => handleError(error, `send fail in ${channel.id} after webhook send fail`));
|
||||
});
|
||||
|
||||
}
|
||||
var d = new DiscordMessageSender(channel);
|
||||
|
||||
const gClient = new Client(uri);
|
||||
if (uri == "wss://mppclone.com:8443") gClient.token = config.mpc_token; //todo hmm
|
||||
if (uri == "wss://backend.multiplayerpiano.net") gClient.token = config.mpc_token; //todo hmm
|
||||
gClient.setChannel(room, {visible:false});
|
||||
gClient.start();
|
||||
|
||||
@@ -41,16 +22,16 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
let lastError;
|
||||
gClient.on("error", error => {
|
||||
handleError(error, `[${uri}][${room}]`);
|
||||
error = error.toString();
|
||||
error = error.message || JSON.stringify(error);
|
||||
if (lastError != error) {
|
||||
dSend(`**${error.toString()}**`);
|
||||
d.send(`**${error}**`);
|
||||
lastError = error;
|
||||
}
|
||||
});
|
||||
var isConnected = false; // TODO use gClient.isConnected() ?
|
||||
gClient.on('connect', () => {
|
||||
console.log(`[${uri}][${room}] Connected to server`);
|
||||
dSend(`**Connected to server; joining channel…**`);
|
||||
d.send(`**Connected to server; joining channel…**`);
|
||||
isConnected = true;
|
||||
lastError = undefined;
|
||||
});
|
||||
@@ -64,7 +45,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
gClient.on('disconnect', () => {
|
||||
if (isConnected) {
|
||||
console.log(`[${uri}][${room}] Disconnected from server`);
|
||||
dSend(`**Disconnected from server**`);
|
||||
d.send(`**Disconnected from server**`);
|
||||
isConnected = false;
|
||||
}
|
||||
});
|
||||
@@ -80,12 +61,12 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
gClient.on('ch', async msg => {
|
||||
// announce channel join
|
||||
if (!lastCh) {
|
||||
dSend(`**Joined channel \`${msg.ch._id}\`**`);
|
||||
d.send(`**Joined channel \`${msg.ch._id}\`**`);
|
||||
console.log(`[${uri}][${room}] Joined channel ${msg.ch._id}`);
|
||||
}
|
||||
// announce channel change
|
||||
else if (msg.ch._id !== lastCh) {
|
||||
dSend(`**Channel changed from \`${lastCh}\` to \`${msg.ch._id}\`**`);
|
||||
d.send(`**Channel changed from \`${lastCh}\` to \`${msg.ch._id}\`**`);
|
||||
console.log(`[${uri}][${room}] Channel changed from ${lastCh} to ${msg.ch._id}`);
|
||||
}
|
||||
lastCh = msg.ch._id;
|
||||
@@ -97,12 +78,12 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
|
||||
// MPP to Discord
|
||||
gClient.on('a', async msg => {
|
||||
if (msg.p._id == gClient.getOwnParticipant()._id) return;
|
||||
if (msg.p._id == gClient.user._id) return;
|
||||
var id = msg.p._id.substr(0,6);
|
||||
var name = sanitizeName(msg.p.name);
|
||||
var content = msg.a;
|
||||
var str = `\`${id}\` **${name}:** ${content}`;
|
||||
dSend(str);
|
||||
d.send(str);
|
||||
});
|
||||
|
||||
// Discord to MPP
|
||||
@@ -138,15 +119,17 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
gClient.prependListener("p", async participant => {
|
||||
if (gClient.ppl[participant.id]) { // is update
|
||||
let oldName = gClient.ppl[participant.id].name, newName = participant.name;
|
||||
if (newName != oldName)
|
||||
dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(oldName)}** changed their name to **${sanitizeName(newName)}**___`);
|
||||
let isBot = gClient.ppl[participant.id].tag?.text == "BOT";
|
||||
if (newName != oldName && !isBot)
|
||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(oldName)}** changed their name to **${sanitizeName(newName)}**___`);
|
||||
} else { // is join
|
||||
dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`);
|
||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`);
|
||||
}
|
||||
});
|
||||
gClient.prependListener("bye", async msg => {
|
||||
var participant = gClient.ppl[msg.p];
|
||||
dSend(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** left the room.___`);
|
||||
if (!participant) return;
|
||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** left the room.___`);
|
||||
});
|
||||
|
||||
|
||||
@@ -154,10 +137,10 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
// on notifications
|
||||
gClient.on('notification', async msg => {
|
||||
// show notification
|
||||
dSend(undefined, {embeds:[{
|
||||
d.sendEmbed({
|
||||
title: msg.title,
|
||||
description: msg.text || msg.html
|
||||
}]});
|
||||
});
|
||||
|
||||
// handle bans
|
||||
if (msg.text && (msg.text.startsWith('Banned from "'+room+'"') || msg.text.startsWith('Currently banned from "'+room+'"'))) {
|
||||
@@ -172,7 +155,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
gClient.setChannel(room);
|
||||
gClient.start();
|
||||
}, minutes*60*1000+3000);
|
||||
dSend(`**Attempting to rejoin in ${minutes} minutes.**`);
|
||||
d.send(`**Attempting to rejoin in ${minutes} minutes.**`);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -190,14 +173,15 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
|
||||
|
||||
// addons
|
||||
{
|
||||
// record raw data
|
||||
let createWSMessageCollector = require("./datacollector")
|
||||
gClient.on("message", createWSMessageCollector(async function(data, startDate, endDate){
|
||||
var wsc = new WebSocketMessageCollector(async function(data, startDate, endDate) {
|
||||
var attachmentName = `${uri} ${room} raw data recording from ${startDate.toISOString()} to ${endDate.toISOString()} .txt.gz`;
|
||||
await channel.send(new Discord.MessageAttachment(data, attachmentName));
|
||||
}));
|
||||
}
|
||||
await channel.send({files:[{
|
||||
attachment: data,
|
||||
name: attachmentName
|
||||
}]});
|
||||
});
|
||||
gClient.on("message", wsc.collect.bind(wsc));
|
||||
|
||||
|
||||
return gClient;
|
||||
};
|
||||
@@ -205,7 +189,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
||||
|
||||
|
||||
// start
|
||||
client.once("ready", async function () {
|
||||
dClient.once("ready", async function () {
|
||||
global.bridges = require("./bridges");
|
||||
for (let bridge of bridges) {
|
||||
try {
|
||||
|
||||
Generated
+523
-412
File diff suppressed because it is too large
Load Diff
+3
-4
@@ -1,9 +1,8 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"async-exit-hook": "^2.0.1",
|
||||
"discord.js": "^13.5.0",
|
||||
"dotenv": "^8.2.0",
|
||||
"socketcluster-client": "^14.2.2",
|
||||
"ws": "^3.3.2"
|
||||
"discord.js": "^13.17.1",
|
||||
"dotenv": "^8.6.0",
|
||||
"ws": "^8.18.3"
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,48 +0,0 @@
|
||||
const socketCluster = require("socketcluster-client")
|
||||
const EventEmitter = require("events").EventEmitter;
|
||||
class PRClient extends EventEmitter {
|
||||
constructor(credentials, options) {
|
||||
super()
|
||||
EventEmitter.call(this);
|
||||
this.options = options;
|
||||
this.socket;
|
||||
this.channels = {};
|
||||
this.credentials = credentials
|
||||
}
|
||||
connect() {
|
||||
if (!this.options) {
|
||||
this.options = {
|
||||
path: "/socketcluster/",
|
||||
hostname: "www.pianorhythm.me",
|
||||
port: 443,
|
||||
secure: true,
|
||||
autoReconnect: true,
|
||||
}
|
||||
}
|
||||
// Initiate the connection to the server
|
||||
this.socket = socketCluster.connect(this.options);
|
||||
this.socket.connect();
|
||||
this.socket.on("error", (msg) => {
|
||||
handleError(msg, "pr socket");
|
||||
})
|
||||
this.socket.on("connect", () => {
|
||||
console.log("Connected!")
|
||||
this.socket.emit("enableAuthLogin", {
|
||||
enable: true,
|
||||
roomName: this.credentials.roomName
|
||||
});
|
||||
this.socket.emit("enableCursor", {
|
||||
enable: true
|
||||
});
|
||||
this.socket.emit("login", {
|
||||
password: this.credentials.password,
|
||||
roomName: this.credentials.roomName,
|
||||
username: this.credentials.username
|
||||
});
|
||||
this.socket.emit("getPlayerStats", {
|
||||
"username": this.credentials.username
|
||||
})
|
||||
})
|
||||
}
|
||||
}
|
||||
module.exports = PRClient;
|
||||
@@ -1,54 +0,0 @@
|
||||
const PRClient = require("./PRClient.js");
|
||||
|
||||
let client = new PRClient({// account stuff
|
||||
username: "Discord",
|
||||
password: config.pr_password,
|
||||
roomName: 'lobby'
|
||||
});
|
||||
global.prClient = client;
|
||||
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);
|
||||
})
|
||||
|
||||
async function messagehandle(data) {
|
||||
if (data && data.type) {
|
||||
switch (data.type) {
|
||||
case "chat":
|
||||
if (data && data.message) {
|
||||
let name = data.name || "";
|
||||
let effect = data.effect || "";
|
||||
let roomName = data.roomName;
|
||||
let color = data.color;
|
||||
let id = data.sID || data.socketID || data.id;
|
||||
if (id == client.socket.id) return;
|
||||
let c = dClient.channels.resolve("593943518351982603");
|
||||
let msg;
|
||||
(!name && (data.message.startsWith("[i]"))) ? msg = `*${data.message.split("[i]")[1]}*` : msg = `**${sanitizeName(name)}:** ${data.message}`;
|
||||
if (c) c.send(msg);
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dClient.on("messageCreate", async message => {
|
||||
if (message.channel.id != "593943518351982603" || message.author.id == dClient.user.id) return;
|
||||
if (!client.roomID) return;
|
||||
client.socket.publish(client.roomID, {
|
||||
"type": "chat",
|
||||
"message": `${message.member && message.member.displayName || message.author.username}#${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]"
|
||||
});
|
||||
});
|
||||
@@ -1,5 +0,0 @@
|
||||
FROM buildkite/puppeteer
|
||||
ADD . /app
|
||||
WORKDIR /app
|
||||
RUN npm ci
|
||||
CMD ["node", "screenshotter.js"]
|
||||
Generated
-1255
File diff suppressed because it is too large
Load Diff
@@ -1,7 +0,0 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"discord.js": "^12.5.3",
|
||||
"dotenv": "^10.0.0",
|
||||
"puppeteer": "^10.2.0"
|
||||
}
|
||||
}
|
||||
@@ -1,72 +0,0 @@
|
||||
require("dotenv").config();
|
||||
var Discord = require("discord.js");
|
||||
var puppeteer = require('puppeteer');
|
||||
|
||||
var wh_hmpps = new Discord.WebhookClient(process.env.WH_HMPPS_ID, process.env.WH_HMPPS_TOKEN);
|
||||
var wh_hrprs = new Discord.WebhookClient(process.env.WH_HRPRS_ID, process.env.WH_HRPRS_TOKEN);
|
||||
var wh_howps = new Discord.WebhookClient(process.env.WH_HOWPS_ID, process.env.WH_HOWPS_TOKEN);
|
||||
|
||||
global.screenshotter = {
|
||||
capture: async function () {
|
||||
console.log('Starting screen captures');
|
||||
try {
|
||||
var browser = await puppeteer.launch(/*{ args: ['--no-sandbox'] }*/);
|
||||
var page = await browser.newPage();
|
||||
await page.setViewport({ width: 1440, height: 900 });
|
||||
try {
|
||||
await page.goto('https://www.multiplayerpiano.com/');
|
||||
try {await page.evaluate(function () {
|
||||
document.getElementById('modal').click();
|
||||
//MPP.client.uri = "wss://mpp_proxy.qonq.gq";
|
||||
});} catch(e) {console.error(e.message)}
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
let screenshot = await page.screenshot({ type: 'png' });
|
||||
let filename = `Screenshot of www.multiplayerpiano.com @ ${new Date().toISOString()}.png`;
|
||||
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
||||
await wh_hmpps.send(attachment);
|
||||
} catch (error) {
|
||||
await wh_hmpps.send(`:warning: ${error.stack}`);
|
||||
}
|
||||
try {
|
||||
await page.evaluate(function () {
|
||||
MPP.client.setChannel("✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧");
|
||||
});
|
||||
await new Promise(resolve => setTimeout(resolve, 5000));
|
||||
let screenshot = await page.screenshot({ type: 'png' });
|
||||
let filename = `Screenshot of www.multiplayerpiano.com/✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧ @ ${new Date().toISOString()}.png`;
|
||||
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
||||
await wh_hrprs.send(attachment);
|
||||
} catch(error) {
|
||||
await wh_hrprs.send(`:warning: ${error.stack}`);
|
||||
}
|
||||
try {
|
||||
await page.goto('http://ourworldofpixels.com');
|
||||
await page.evaluate(function (owopcaptcha) {
|
||||
localStorage.owopcaptcha = owopcaptcha;
|
||||
OWOP.camera.zoom = 1;
|
||||
}, process.env.OWOP_CAPTCHA_PASSWORD);
|
||||
await new Promise(resolve => setTimeout(resolve, 2000));
|
||||
await page.evaluate(function () {
|
||||
for (let butt of document.getElementsByTagName('button')) {
|
||||
if (butt.innerText == 'OK') {butt.click();break}
|
||||
}
|
||||
});
|
||||
await new Promise(resolve => setTimeout(resolve, 13000));
|
||||
let screenshot = await page.screenshot({ type: 'png' });
|
||||
let filename = `Screenshot of ourworldofpixels.com/main @ ${new Date().toISOString()}.png`;
|
||||
let attachment = new Discord.MessageAttachment(screenshot, filename);
|
||||
await wh_howps.send(attachment);
|
||||
} catch (error) {
|
||||
await wh_howps.send(`:warning: ${error.stack}`);
|
||||
}
|
||||
} catch(error) {
|
||||
console.error(`Error occured with screen capture:\n${error.stack}`)
|
||||
} finally {
|
||||
if (browser) await browser.close();
|
||||
console.log('Finished screen captures');
|
||||
}
|
||||
},
|
||||
interval: setInterval(() => { screenshotter.capture(); }, 1000 * 60 * 60)
|
||||
};
|
||||
|
||||
screenshotter.capture();
|
||||
Reference in New Issue
Block a user