Compare commits
16 Commits
1af74e957d
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
| 0121a48063 | |||
| 525346ddcf | |||
| dff251d33d | |||
| 7e64c4379e | |||
| f3f8a35107 | |||
| 39adc796d0 | |||
| 5ac9604504 | |||
| 2527a331a7 | |||
| 17052a9ffe | |||
| e0dea9ebf4 | |||
| 4a40060439 | |||
| b507813f0a | |||
| 5476ecf714 | |||
| ef4ccb8bc0 | |||
| 995ac6d96f | |||
| e21a264ed0 |
+5
-5
@@ -3,11 +3,11 @@
|
|||||||
{ "room": "lobby2", "channel": "1159954805146529823", "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": "test/awkward", "channel": "1159954847542546513", "uri": "wss://game.multiplayerpiano.com:443" },
|
||||||
|
|
||||||
{ "room": "lobby", "channel": "339609383644168195", "uri": "wss://mppclone.com:8443" },
|
{ "room": "lobby", "channel": "339609383644168195", "uri": "wss://backend.multiplayerpiano.net" },
|
||||||
{ "room": "lobby2", "channel": "350006891948277770", "uri": "wss://mppclone.com:8443" },
|
{ "room": "lobby2", "channel": "350006891948277770", "uri": "wss://backend.multiplayerpiano.net" },
|
||||||
{ "room": "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧", "channel": "698736467559710740", "uri": "wss://mppclone.com:8443" },
|
{ "room": "✧𝓓𝓔𝓥 𝓡𝓸𝓸𝓶✧", "channel": "698736467559710740", "uri": "wss://backend.multiplayerpiano.net" },
|
||||||
{ "room": "test/awkward", "channel": "360556775860076544", "uri": "wss://mppclone.com:8443" },
|
{ "room": "test/awkward", "channel": "360556775860076544", "uri": "wss://backend.multiplayerpiano.net" },
|
||||||
{ "room": "test/fishing", "channel": "339613702472859659", "uri": "wss://mppclone.com:8443" },
|
{ "room": "test/fishing", "channel": "339613702472859659", "uri": "wss://backend.multiplayerpiano.net" },
|
||||||
|
|
||||||
{ "room": "lobby", "channel": "339904195719200768", "uri": "wss://piano.ourworldofpixels.com" }
|
{ "room": "lobby", "channel": "339904195719200768", "uri": "wss://piano.ourworldofpixels.com" }
|
||||||
]
|
]
|
||||||
|
|||||||
@@ -1,47 +1,47 @@
|
|||||||
global.testmode = process.env.TEST ? true : false;
|
global.testmode = process.env.TEST ? true : false;
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
|
|
||||||
"DISCORD_TOKEN": process.env.DISCORD_TOKEN,
|
"DISCORD_TOKEN": process.env.DISCORD_TOKEN,
|
||||||
|
|
||||||
"webhooks": {
|
"webhooks": {
|
||||||
"welcome": process.env.WEBHOOK_WELCOME,
|
"welcome": process.env.WEBHOOK_WELCOME,
|
||||||
"error": process.env.WEBHOOK_ERROR,
|
"error": process.env.WEBHOOK_ERROR,
|
||||||
"ddp": process.env.WEBHOOK_DDP,
|
"ddp": process.env.WEBHOOK_DDP,
|
||||||
"pinboard": process.env.WEBHOOK_PINBOARD
|
"pinboard": process.env.WEBHOOK_PINBOARD
|
||||||
},
|
},
|
||||||
|
|
||||||
"opID": "330499035419115522",
|
"opID": "330499035419115522",
|
||||||
"guildID": testmode ? "467473467634089985" : "321819041348190249",
|
"guildID": testmode ? "467473467634089985" : "321819041348190249",
|
||||||
|
|
||||||
"channels": { // includes voice channels & category channels
|
"channels": { // includes voice channels & category channels
|
||||||
"main": testmode ? "467473467634089987" : "321819041348190249",
|
"main": testmode ? "467473467634089987" : "321819041348190249",
|
||||||
"view_deleted_channels": testmode ? "467473467634089989" : "425060452129701889",
|
"view_deleted_channels": testmode ? "467473467634089989" : "425060452129701889",
|
||||||
"name_collection": testmode ? "467481952728121345" : '379738469511069698',
|
"name_collection": testmode ? "467481952728121345" : '379738469511069698',
|
||||||
"mpp_bridges": testmode ? "467481904707534850" : '360557444952227851',
|
"mpp_bridges": testmode ? "467481904707534850" : '360557444952227851',
|
||||||
"user_channels": testmode ? "467482031157149709" : '399735134061985792',
|
"user_channels": testmode ? "467482031157149709" : '399735134061985792',
|
||||||
"deleted_channels": testmode ? "467482085657935872" : '425054198699261953',
|
"deleted_channels": testmode ? "467482085657935872" : '425054198699261953',
|
||||||
"deleted_bridges": testmode ? "467482121657778176" : '696954288752164914',
|
"deleted_bridges": testmode ? "467482121657778176" : '696954288752164914',
|
||||||
"mpp_screenshot": testmode ? "467482164611514388" : '383773548810076163',
|
"mpp_screenshot": testmode ? "467482164611514388" : '383773548810076163',
|
||||||
"owop_screenshot": testmode ? "467482202217906226" : '399079481161023492'
|
"owop_screenshot": testmode ? "467482202217906226" : '399079481161023492'
|
||||||
},
|
},
|
||||||
|
|
||||||
"roles": {
|
"roles": {
|
||||||
"viewing_deleted_channels": testmode ? "467473718353068042" : "425060792455397376",
|
"viewing_deleted_channels": testmode ? "467473718353068042" : "425060792455397376",
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"mppname": "[discord.gg/k44Eqha]",
|
"mppname": "[discord.gg/k44Eqha]",
|
||||||
"disabledRooms": [
|
"disabledRooms": [
|
||||||
"RP Room",
|
"RP Room",
|
||||||
"Legends of Alorgon {RP Room}",
|
"Legends of Alorgon {RP Room}",
|
||||||
"Legends of Alorgon",
|
"Legends of Alorgon",
|
||||||
"Breastmilk ♥ 7:45 AM"
|
"Breastmilk ♥ 7:45 AM"
|
||||||
],
|
],
|
||||||
|
|
||||||
"owop_captcha_password": process.env.OWOP_CAPTCHA_PASSWORD,
|
"owop_captcha_password": process.env.OWOP_CAPTCHA_PASSWORD,
|
||||||
"pr_password": process.env.PR_PASSWORD,
|
"pr_password": process.env.PR_PASSWORD,
|
||||||
"mpc_token": process.env.MPC_TOKEN,
|
"mpc_token": process.env.MPC_TOKEN,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
+40
-40
@@ -9,56 +9,56 @@ var wasConnected = false;
|
|||||||
//var myId;
|
//var myId;
|
||||||
|
|
||||||
var wsc = new WebSocketMessageCollector(async function(data, startDate, endDate){
|
var wsc = new WebSocketMessageCollector(async function(data, startDate, endDate){
|
||||||
await webhook.send({files:[{
|
await webhook.send({files:[{
|
||||||
attachment: data,
|
attachment: data,
|
||||||
name: `daydun piano main raw data recording from ${startDate.toISOString()} to ${endDate.toISOString()} .txt.gz`
|
name: `daydun piano main raw data recording from ${startDate.toISOString()} to ${endDate.toISOString()} .txt.gz`
|
||||||
}]});
|
}]});
|
||||||
});
|
});
|
||||||
|
|
||||||
(function connect() {
|
(function connect() {
|
||||||
ws = new WebSocket("wss://daydun.com:5012/?nick=%5Bdiscord.gg%2Fk44Eqha%5D");
|
ws = new WebSocket("wss://daydun.com:5012/?nick=%5Bdiscord.gg%2Fk44Eqha%5D");
|
||||||
ws.on("open", () => {
|
ws.on("open", () => {
|
||||||
if (!wasConnected) send2discord("**Connected**");
|
if (!wasConnected) send2discord("**Connected**");
|
||||||
wasConnected = true;
|
wasConnected = true;
|
||||||
});
|
});
|
||||||
ws.on("message", message => {
|
ws.on("message", message => {
|
||||||
wsc.collect(message);
|
wsc.collect(message);
|
||||||
if (typeof message != 'string') return;
|
if (typeof message != 'string') return;
|
||||||
var transmission = JSON.parse(message);
|
var transmission = JSON.parse(message);
|
||||||
if (transmission.type == 'chat') {
|
if (transmission.type == 'chat') {
|
||||||
let chatmsg = transmission.message;
|
let chatmsg = transmission.message;
|
||||||
if (chatmsg.type == "message") {
|
if (chatmsg.type == "message") {
|
||||||
//if (chatmsg.id != myId)
|
//if (chatmsg.id != myId)
|
||||||
if (!chatmsg.content.startsWith('\u034f'))
|
if (!chatmsg.content.startsWith('\u034f'))
|
||||||
send2discord(`**${sanitizeName(chatmsg.user.nick)}:** ${chatmsg.content}`);
|
send2discord(`**${sanitizeName(chatmsg.user.nick)}:** ${chatmsg.content}`);
|
||||||
} else if (chatmsg.type == "join") {
|
} else if (chatmsg.type == "join") {
|
||||||
send2discord(`__***${sanitizeName(chatmsg.nick || chatmsg.id)} joined.***__`);
|
send2discord(`__***${sanitizeName(chatmsg.nick || chatmsg.id)} joined.***__`);
|
||||||
} else if (chatmsg.type == "leave") {
|
} else if (chatmsg.type == "leave") {
|
||||||
send2discord(`__***${sanitizeName(chatmsg.nick || chatmsg.id)} left.***__`);
|
send2discord(`__***${sanitizeName(chatmsg.nick || chatmsg.id)} left.***__`);
|
||||||
}
|
}
|
||||||
} /*else if (transmission.type == 'load') {
|
} /*else if (transmission.type == 'load') {
|
||||||
myId = transmission.id;
|
myId = transmission.id;
|
||||||
}*/
|
}*/
|
||||||
});
|
});
|
||||||
ws.on("error", error => handleError(error));
|
ws.on("error", error => handleError(error));
|
||||||
ws.on("close", () => {
|
ws.on("close", () => {
|
||||||
if (wasConnected) send2discord("**Disconnected**");
|
if (wasConnected) send2discord("**Disconnected**");
|
||||||
wasConnected = false;
|
wasConnected = false;
|
||||||
setTimeout(connect, 5000);
|
setTimeout(connect, 5000);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
function send2discord(message) {
|
function send2discord(message) {
|
||||||
webhook.send(message.substring(0,2000));
|
webhook.send(message.substring(0,2000));
|
||||||
}
|
}
|
||||||
|
|
||||||
function send2ddp(message) {
|
function send2ddp(message) {
|
||||||
if (ws.readyState == WebSocket.OPEN) ws.send(JSON.stringify({type:"chat",message}));
|
if (ws.readyState == WebSocket.OPEN) ws.send(JSON.stringify({type:"chat",message}));
|
||||||
}
|
}
|
||||||
|
|
||||||
dClient.on("messageCreate", message => {
|
dClient.on("messageCreate", message => {
|
||||||
if (message.channel.id != "508890674138054667" || message.author.bot) return;
|
if (message.channel.id != "508890674138054667" || message.author.bot) return;
|
||||||
var x = message.cleanContent;
|
var x = message.cleanContent;
|
||||||
if (message.attachments.size > 0) x += ' ' + message.attachments.map(a => a.url).join(' ');
|
if (message.attachments.size > 0) x += ' ' + message.attachments.map(a => a.url).join(' ');
|
||||||
send2ddp(`\u034f${message.member.displayName}#${message.author.discriminator}: ${x}`);
|
send2ddp(`\u034f${message.member.displayName}#${message.author.discriminator}: ${x}`);
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -76,7 +76,7 @@ Client.prototype.connect = function() {
|
|||||||
if(typeof module !== "undefined") {
|
if(typeof module !== "undefined") {
|
||||||
let headers = {
|
let headers = {
|
||||||
"origin": `https://${new URL(this.uri).host}`,
|
"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/86.0.4240.75 Safari/537.36"
|
"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)}`;
|
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
|
// nodejsicle
|
||||||
@@ -105,7 +105,7 @@ Client.prototype.connect = function() {
|
|||||||
} else {
|
} else {
|
||||||
++self.connectionAttempts;
|
++self.connectionAttempts;
|
||||||
}
|
}
|
||||||
var ms_lut = [50, 2950, 7000, 10000];
|
var ms_lut = [50, 2950, 7000, 10000, 30000, 60000];
|
||||||
var idx = self.connectionAttempts;
|
var idx = self.connectionAttempts;
|
||||||
if(idx >= ms_lut.length) idx = ms_lut.length - 1;
|
if(idx >= ms_lut.length) idx = ms_lut.length - 1;
|
||||||
var ms = ms_lut[idx];
|
var ms = ms_lut[idx];
|
||||||
|
|||||||
+22
-22
@@ -1,28 +1,28 @@
|
|||||||
var gzip = require("util").promisify(require("zlib").gzip);
|
var gzip = require("util").promisify(require("zlib").gzip);
|
||||||
|
|
||||||
module.exports = class WebSocketMessageCollector {
|
module.exports = class WebSocketMessageCollector {
|
||||||
constructor(dispatchFunction) {
|
constructor(dispatchFunction) {
|
||||||
this.maxSize = 8000000;
|
this.maxSize = 8000000;
|
||||||
this.data = "";
|
this.data = "";
|
||||||
this.startDate = new Date();
|
this.startDate = new Date();
|
||||||
this.dispatchFunction = dispatchFunction;
|
this.dispatchFunction = dispatchFunction;
|
||||||
exitHook(cb => {
|
exitHook(cb => {
|
||||||
this.package().then(cb);
|
this.package().then(cb);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
collect(message) {
|
collect(message) {
|
||||||
message = message.data || message;
|
message = message.data || message;
|
||||||
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString('base64');
|
if (message instanceof ArrayBuffer) message = Buffer.from(message).toString('base64');
|
||||||
var line = `${Date.now()} ${message}\n`;
|
var line = `${Date.now()} ${message}\n`;
|
||||||
this.data += line;
|
this.data += line;
|
||||||
if (this.data.length > this.maxSize) this.package();
|
if (this.data.length > this.maxSize) this.package();
|
||||||
}
|
}
|
||||||
|
|
||||||
async package() {
|
async package() {
|
||||||
var data = this.data, startDate = this.startDate, endDate = new Date();
|
var data = this.data, startDate = this.startDate, endDate = new Date();
|
||||||
this.data = "", this.startDate = new Date();
|
this.data = "", this.startDate = new Date();
|
||||||
data = await gzip(data);
|
data = await gzip(data);
|
||||||
await this.dispatchFunction(data, startDate, endDate);
|
await this.dispatchFunction(data, startDate, endDate);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -18,7 +18,7 @@ global.dClient = new Discord.Client({
|
|||||||
let msg = error && (error.stack || error.message || error);
|
let msg = error && (error.stack || error.message || error);
|
||||||
console.error(title + ':\n' + msg);
|
console.error(title + ':\n' + msg);
|
||||||
try {
|
try {
|
||||||
webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
|
//webhook.send(`${title ? `**${title}:**` : ""}\`\`\`\n${msg}\n\`\`\``).catch(()=>{});
|
||||||
} catch(e) {}
|
} catch(e) {}
|
||||||
}
|
}
|
||||||
process.on('unhandledRejection', error => handleError(error, "Unhandled Rejection"));
|
process.on('unhandledRejection', error => handleError(error, "Unhandled Rejection"));
|
||||||
|
|||||||
@@ -1,83 +1,73 @@
|
|||||||
// join/leave
|
// join/leave
|
||||||
(async function(){
|
(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 => {
|
dClient.on('guildMemberAdd', async member => {
|
||||||
if (member.guild.id != config.guildID) return;
|
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;
|
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} joined.`, username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
|
webhook.send({content: `${member} joined.`, username, avatarURL: member.user.displayAvatarURL({format:'png',size:2048})});
|
||||||
});
|
});
|
||||||
dClient.on('guildMemberRemove', async member => {
|
dClient.on('guildMemberRemove', async member => {
|
||||||
if (member.guild.id != config.guildID) return;
|
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;
|
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})});
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// view deleted channels
|
// view deleted channels
|
||||||
(async function(){
|
(async function(){
|
||||||
dClient.on('voiceStateUpdate', async (oldState, newState) => {
|
dClient.on('voiceStateUpdate', async (oldState, newState) => {
|
||||||
if (oldState.channelId != config.channels.view_deleted_channels && newState.channelId == config.channels.view_deleted_channels) {
|
if (oldState.channelId != config.channels.view_deleted_channels && newState.channelId == config.channels.view_deleted_channels) {
|
||||||
// member joined the channel
|
// member joined the channel
|
||||||
newState.member.roles.add(config.roles.viewing_deleted_channels);
|
newState.member.roles.add(config.roles.viewing_deleted_channels);
|
||||||
} else if (oldState.channelId == config.channels.view_deleted_channels && newState.channelId != config.channels.view_deleted_channels) {
|
} else if (oldState.channelId == config.channels.view_deleted_channels && newState.channelId != config.channels.view_deleted_channels) {
|
||||||
// member left the channel
|
// member left the channel
|
||||||
newState.member.roles.remove(config.roles.viewing_deleted_channels);
|
newState.member.roles.remove(config.roles.viewing_deleted_channels);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// arrange bots at bottom of list
|
// arrange bots at bottom of list
|
||||||
(async function(){
|
(async function(){
|
||||||
let prefix = "\u17b5";
|
let prefix = "\u17b5";
|
||||||
let onNick = async member => {
|
let onNick = async member => {
|
||||||
if (member.guild.id != config.guildID) return;
|
if (member.guild.id != config.guildID) return;
|
||||||
if (member.user.bot && !member.displayName.startsWith(prefix))
|
if (member.user.bot && !member.displayName.startsWith(prefix))
|
||||||
await member.setNickname(`${prefix}${member.displayName}`.substring(0,32));
|
await member.setNickname(`${prefix}${member.displayName}`.substring(0,32));
|
||||||
};
|
};
|
||||||
dClient.on('guildMemberAdd', onNick);
|
dClient.on('guildMemberAdd', onNick);
|
||||||
dClient.on('guildMemberUpdate', async (oldMember, newMember) => {
|
dClient.on('guildMemberUpdate', async (oldMember, newMember) => {
|
||||||
if (newMember.displayName != oldMember.displayName) await onNick(newMember);
|
if (newMember.displayName != oldMember.displayName) await onNick(newMember);
|
||||||
});
|
});
|
||||||
})();
|
})();
|
||||||
|
|
||||||
|
|
||||||
// persistent emojis
|
// persistent emojis
|
||||||
dClient.on("emojiDelete", async emoji => {
|
dClient.on("emojiDelete", async emoji => {
|
||||||
console.log("emoji deleted:", emoji.name, emoji.url);
|
console.log("emoji deleted:", emoji.name, emoji.url);
|
||||||
if (global.disableEmojiProtection) return;
|
if (global.disableEmojiProtection) return;
|
||||||
if (emoji.name.toLowerCase().includes('delete')) return;
|
if (emoji.name.toLowerCase().includes('delete')) return;
|
||||||
async function readdEmoji() {
|
async function readdEmoji() {
|
||||||
await emoji.guild.emojis.create(emoji.url, emoji.name);
|
await emoji.guild.emojis.create(emoji.url, emoji.name);
|
||||||
delete readdEmoji;
|
delete readdEmoji;
|
||||||
}
|
}
|
||||||
// re-add emoji in 5 to 10 minutes
|
// re-add emoji in 5 to 10 minutes
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (readdEmoji) readdEmoji();
|
if (readdEmoji) readdEmoji();
|
||||||
}, 300000 + Math.random() * 300000);
|
}, 300000 + Math.random() * 300000);
|
||||||
// wouldn't want emoji to be lost if process is stopped before timeout ends
|
// wouldn't want emoji to be lost if process is stopped before timeout ends
|
||||||
exitHook(callback => {
|
exitHook(callback => {
|
||||||
if (readdEmoji) readdEmoji().then(() => callback());
|
if (readdEmoji) readdEmoji().then(() => callback());
|
||||||
else callback();
|
else callback();
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// allow anyone to pin a message via reaction
|
// allow anyone to pin a message via reaction
|
||||||
// todo need enable partials for it to work on old messages
|
// todo need enable partials for it to work on old messages
|
||||||
dClient.on("messageReactionAdd", async (messageReaction) => {
|
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 == "📍")
|
if (messageReaction.emoji.name == "📌" || messageReaction.emoji.name == "📍")
|
||||||
await messageReaction.message.pin();
|
await messageReaction.message.pin();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+19
-18
@@ -7,7 +7,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
var d = new DiscordMessageSender(channel);
|
var d = new DiscordMessageSender(channel);
|
||||||
|
|
||||||
const gClient = new Client(uri);
|
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.setChannel(room, {visible:false});
|
||||||
gClient.start();
|
gClient.start();
|
||||||
|
|
||||||
@@ -21,10 +21,10 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
|
|
||||||
let lastError;
|
let lastError;
|
||||||
gClient.on("error", error => {
|
gClient.on("error", error => {
|
||||||
//handleError(error, `[${uri}][${room}]`);
|
handleError(error, `[${uri}][${room}]`);
|
||||||
error = error.toString();
|
error = error.message || JSON.stringify(error);
|
||||||
if (lastError != error) {
|
if (lastError != error) {
|
||||||
d.send(`**${error.toString()}**`);
|
d.send(`**${error}**`);
|
||||||
lastError = error;
|
lastError = error;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -78,7 +78,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
|
|
||||||
// MPP to Discord
|
// MPP to Discord
|
||||||
gClient.on('a', async msg => {
|
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 id = msg.p._id.substr(0,6);
|
||||||
var name = sanitizeName(msg.p.name);
|
var name = sanitizeName(msg.p.name);
|
||||||
var content = msg.a;
|
var content = msg.a;
|
||||||
@@ -117,19 +117,20 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
|
|
||||||
// announce join/leave/rename
|
// announce join/leave/rename
|
||||||
gClient.prependListener("p", async participant => {
|
gClient.prependListener("p", async participant => {
|
||||||
if (gClient.ppl[participant.id]) { // is update
|
if (gClient.ppl[participant.id]) { // is update
|
||||||
let oldName = gClient.ppl[participant.id].name, newName = participant.name;
|
let oldName = gClient.ppl[participant.id].name, newName = participant.name;
|
||||||
if (newName != oldName)
|
let isBot = gClient.ppl[participant.id].tag?.text == "BOT";
|
||||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(oldName)}** changed their name to **${sanitizeName(newName)}**___`);
|
if (newName != oldName && !isBot)
|
||||||
} else { // is join
|
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(oldName)}** changed their name to **${sanitizeName(newName)}**___`);
|
||||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`);
|
} else { // is join
|
||||||
}
|
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** entered the room.___`);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
gClient.prependListener("bye", async msg => {
|
gClient.prependListener("bye", async msg => {
|
||||||
var participant = gClient.ppl[msg.p];
|
var participant = gClient.ppl[msg.p];
|
||||||
if (!participant) return;
|
if (!participant) return;
|
||||||
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** left the room.___`);
|
d.send(`\`${participant._id.substr(0,6)}\` ___**${sanitizeName(participant.name)}** left the room.___`);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -143,8 +144,8 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
|
|
||||||
// handle bans
|
// handle bans
|
||||||
if (msg.text && (msg.text.startsWith('Banned from "'+room+'"') || msg.text.startsWith('Currently banned from "'+room+'"'))) {
|
if (msg.text && (msg.text.startsWith('Banned from "'+room+'"') || msg.text.startsWith('Currently banned from "'+room+'"'))) {
|
||||||
// Banned from "{room}" for {n} minutes.
|
// Banned from "{room}" for {n} minutes.
|
||||||
// Currently banned from "{room}" for {n} minutes.
|
// Currently banned from "{room}" for {n} minutes.
|
||||||
let arr = msg.text.split(' ');
|
let arr = msg.text.split(' ');
|
||||||
arr.pop();
|
arr.pop();
|
||||||
let minutes = arr.pop();
|
let minutes = arr.pop();
|
||||||
@@ -170,7 +171,7 @@ global.createMPPbridge = async function createMPPbridge({room, channel, uri}) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// addons
|
// addons
|
||||||
var wsc = new WebSocketMessageCollector(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`;
|
var attachmentName = `${uri} ${room} raw data recording from ${startDate.toISOString()} to ${endDate.toISOString()} .txt.gz`;
|
||||||
|
|||||||
Generated
+527
-416
File diff suppressed because it is too large
Load Diff
+3
-4
@@ -1,9 +1,8 @@
|
|||||||
{
|
{
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"async-exit-hook": "^2.0.1",
|
"async-exit-hook": "^2.0.1",
|
||||||
"discord.js": "^13.5.0",
|
"discord.js": "^13.17.1",
|
||||||
"dotenv": "^8.2.0",
|
"dotenv": "^8.6.0",
|
||||||
"socketcluster-client": "^14.2.2",
|
"ws": "^8.18.3"
|
||||||
"ws": "^3.3.2"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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();
|
|
||||||
@@ -1,11 +1,11 @@
|
|||||||
|
|
||||||
global.random = function (array) {
|
global.random = function (array) {
|
||||||
return array[Math.floor(Math.random() * array.length)]
|
return array[Math.floor(Math.random() * array.length)]
|
||||||
}
|
}
|
||||||
|
|
||||||
global.sanitizeName = function sanitizeName(str){ // for showing names in discord
|
global.sanitizeName = function sanitizeName(str){ // for showing names in discord
|
||||||
str = str.replace(/[_~*\\]/g,"\\$&"); // formatting
|
str = str.replace(/[_~*\\]/g,"\\$&"); // formatting
|
||||||
str = str.replace(/discord.gg\//g, 'discord.gg\\/'); // invites
|
str = str.replace(/discord.gg\//g, 'discord.gg\\/'); // invites
|
||||||
str = str.replace(/(http|https):\/\//g, "$1\\://"); // urls
|
str = str.replace(/(http|https):\/\//g, "$1\\://"); // urls
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user