Delete dead files

This commit is contained in:
ledlamp 2018-05-11 22:25:42 -07:00
parent 79227ee843
commit e46058b8c1
3 changed files with 0 additions and 313 deletions

View File

@ -1,203 +0,0 @@
global.awakensBridge = {}
awakensBridge.connect = function (uri, options) {
var io = require('socket.io-client');
var channel = new Discord.WebhookClient('342850770594562060', config.webhooks.awakens, {disableEveryone:true} );
this.channel = channel;
//test//var channel = new Discord.WebhookClient('399378912020529153', 'wdVr8ZvssmX9IF4cqS9dq3pxTUX9a9dNGN6Pusu5AzX60DQqBsWe6qxLagrFPgxksJQI', {disableEveryone:true} );
var socket = io(uri||`http://this.awakens.me`, options||{
extraHeaders: {
'cf-connecting-ip': randomIp()
}
});
this.socket = socket;
socket.on('connect', function() {
console.log('Connected to awakens.me');
var ip = socket.io && socket.io.opts && socket.io.opts.extraHeaders && socket.io.opts.extraHeaders['cf-connecting-ip'];
channel.send(ip ? `**Connected with fake IP address \`${ip}\`**` : '**Connected**');
socket.emit('requestJoin');
});
socket.on('disconnect', function() {
console.log('Disconnected from awakens.me');
channel.send('**Disconnected**');
});
var online = {};
socket.on('channeldata', (channel) => {
if (channel.users) {
channel.users.forEach(user => {
online[user.id] = user.nick;
});
}
});
socket.on('nick', (id, newNick) => {
var str = `**\\*\\* ${online[id]} is now known as ${newNick} \\*\\***`;
//console.log(str);
channel.send(str);
online[id] = newNick;
});
socket.on('joined', (id, nick) => {
var str = `**\\*\\* ${nick} has joined \\*\\***`;
//console.log(str);
channel.send(str);
online[id] = nick;
});
socket.on('left', (id, part) => {
var str = `**\\*\\* ${online[id]} has left${part ? ": "+part : ""} \\*\\***`;
//console.log(str);
channel.send(str);
});
socket.on('message', function(messageData) {
switch (messageData.messageType) {
default: {
if (typeof messageData.message != 'string') return console.error(messageData);
let msg = messageData.nick ? `**${messageData.nick}:** ${filter(messageData.message)}` : `**\\*\\* ${messageData.message} \\*\\***`;
//console.log(msg);
channel.send(msg, {split:{char:''}});
/*if (messageData.message.startsWith("You've been kicked")) {
console.log('Kicked from ', socket.io.uri);
}
if (messageData.message.startsWith("You've been banned")) {
console.log('Banned from ', socket.io.uri);
}*/
if (messageData.message.startsWith("You've been kicked") || messageData.message.startsWith("You've been banned")) {
let ms = Math.random()*1000000;
setTimeout(function(){
awakensBridge.connect(); // create new socket with different ip header
}, ms);
channel.send(`**Reconnecting in \`${ms/60000}\` minutes.**`);
}
break;
}
case "chat-image": {
let msg = `**${messageData.nick}:**`;
let img = Buffer.from(messageData.message.img, 'binary');
let attachment = new Discord.MessageAttachment(img, 'image.'+messageData.message.type.split('/')[1]);
channel.send(msg, attachment);
}
}
});
/*client.on('message', message => {
if (message.author !== client.user && message.channel === channel) {
socket.emit('message', `/*${message.member.displayName}:| ${message.content}`);
}
});*/
}
awakensBridge.connect();
/////////////////////////////////////////////////////////////////////////
function filter(str) {
// escape
// Convert chars to html codes
//str = str.replace(/\n/g, '\\n');
// str = str.replace(/&/gi, '&');
// str = str.replace(/>/gi, '>');
//str = str.replace(/</gi, '&lt;');
//str = str.replace(/"/gi, '&quot;');
//str = str.replace(/#/gi, '&#35;');
//str = str.replace(/\\n/g, '<br>');
//str = str.replace(/\$/gi, '&#36;');
//str = str.replace(/'/gi, '&#39;');
//str = str.replace(/~/gi, '&#126;');
//convert spaces
//str = str.replace(/\s{2}/gi, ' &nbsp;');
//str = str.replace(/(<br>)(.+)/g, '<div style="display:block;padding-left:3.5em;">$2</div>');
var coloreg = 'yellowgreen|yellow|whitesmoke|white|wheat|violet|turquoise|tomato|thistle|teal|tan|steelblue|springgreen|snow|slategray|slateblue|skyblue|silver|sienna|seashell|seagreen|sandybrown|salmon|saddlebrown|royalblue|rosybrown|red|rebeccapurple|purple|powderblue|plum|pink|peru|peachpuff|papayawhip|palevioletred|paleturquoise|palegreen|palegoldenrod|orchid|orangered|orange|olivedrab|olive|oldlace|navy|navajowhite|moccasin|mistyrose|mintcream|midnightblue|mediumvioletred|mediumturquoise|mediumspringgreen|mediumslateblue|mediumseagreen|mediumpurple|mediumorchid|mediumblue|mediumaquamarine|maroon|magenta|linen|limegreen|lime|lightyellow|lightsteelblue|lightslategray|lightskyblue|lightseagreen|lightsalmon|lightpink|lightgreen|lightgray|lightgoldenrodyellow|lightcyan|lightcoral|lightblue|lemonchiffon|lawngreen|lavenderblush|lavender|khaki|ivory|indigo|indianred|hotpink|honeydew|greenyellow|green|gray|goldenrod|gold|ghostwhite|gainsboro|fuchsia|forestgreen|floralwhite|firebrick|dodgerblue|dimgray|deepskyblue|deeppink|darkviolet|darkturquoise|darkslategray|darkslateblue|darkseagreen|darksalmon|darkred|darkorchid|darkorange|darkolivegreen|darkmagenta|darkkhaki|darkgreen|darkgray|darkgoldenrod|darkcyan|darkblue|cyan|crimson|cornsilk|cornflowerblue|coral|chocolate|chartreuse|cadetblue|transparent|burlywood|brown|blueviolet|blue|blanchedalmond|black|bisque|beige|azure|aquamarine|aqua|antiquewhite|aliceblue';
// fonts
str = str.replace(/(\$|(&#36;))([\w \-\,®]*)\|(.*)$/g, "$4");
str = str.replace(/(\£|(£))([\w \-\,®]*)\|(.*)$/g, "$4");
// colors
str = str.replace(/###([\da-f]{6}|[\da-f]{3})(.+)$/gi, '$2');
str = str.replace(/##([\da-f]{6}|[\da-f]{3})(.+)$/gi, '$2');
str = str.replace(/#([\da-f]{6}|[\da-f]{3})(.+)$/gi, '$2');
str = str.replace(RegExp('###(' + coloreg + ')(.+)$', 'gi'), '$2');
str = str.replace(RegExp('##(' + coloreg + ')(.+)$', 'gi'), '$2');
str = str.replace(RegExp('#(' + coloreg + ')(.+)$', 'gi'), '$2');
// styles
str = str.replace(/\/\%%([^\%%]+)\%%/g, '$1');
str = str.replace(/\/\^([^\|]+)\|?/g, '$1');
str = str.replace(/\/\*([^\|]+)\|?/g, '$1');
str = str.replace(/\/\%([^\|]+)\|?/g, '$1');
str = str.replace(/\/\_([^\|]+)\|?/g, '$1');
str = str.replace(/\/\-([^\|]+)\|?/g, '$1');
str = str.replace(/\/\~([^\|]+)\|?/g, '$1');
str = str.replace(/\/\#([^\|]+)\|?/g, '$1');
str = str.replace(/\/\+([^\|]+)\|?/g, '$1');
str = str.replace(/\/\!([^\|]+)\|?/g, '$1');
str = str.replace(/\/\$([^\|]+)\|?/g, '$1');
str = str.replace(/\/\@([^\|]+)\|?/g, '$1');
return str;
}
/*
function filter(str) {
var multiple = function (str, mtch, rep, limit) {
var ct = 0;
limit = limit || 3000;
while (str.match(mtch) !== null && ct++ < limit) {
str = str.replace(mtch, rep);
}
return str;
};
var coloreg = 'yellowgreen|yellow|whitesmoke|white|wheat|violet|turquoise|tomato|thistle|teal|tan|steelblue|springgreen|snow|slategray|slateblue|skyblue|silver|sienna|seashell|seagreen|sandybrown|salmon|saddlebrown|royalblue|rosybrown|red|rebeccapurple|purple|powderblue|plum|pink|peru|peachpuff|papayawhip|palevioletred|paleturquoise|palegreen|palegoldenrod|orchid|orangered|orange|olivedrab|olive|oldlace|navy|navajowhite|moccasin|mistyrose|mintcream|midnightblue|mediumvioletred|mediumturquoise|mediumspringgreen|mediumslateblue|mediumseagreen|mediumpurple|mediumorchid|mediumblue|mediumaquamarine|maroon|magenta|linen|limegreen|lime|lightyellow|lightsteelblue|lightslategray|lightskyblue|lightseagreen|lightsalmon|lightpink|lightgreen|lightgray|lightgoldenrodyellow|lightcyan|lightcoral|lightblue|lemonchiffon|lawngreen|lavenderblush|lavender|khaki|ivory|indigo|indianred|hotpink|honeydew|greenyellow|green|gray|goldenrod|gold|ghostwhite|gainsboro|fuchsia|forestgreen|floralwhite|firebrick|dodgerblue|dimgray|deepskyblue|deeppink|darkviolet|darkturquoise|darkslategray|darkslateblue|darkseagreen|darksalmon|darkred|darkorchid|darkorange|darkolivegreen|darkmagenta|darkkhaki|darkgreen|darkgray|darkgoldenrod|darkcyan|darkblue|cyan|crimson|cornsilk|cornflowerblue|coral|chocolate|chartreuse|cadetblue|transparent|burlywood|brown|blueviolet|blue|blanchedalmond|black|bisque|beige|azure|aquamarine|aqua|antiquewhite|aliceblue';
// fonts
str = multiple(str, /(\$|(&#36;))([\w \-\,®]*)\|(.*)$/, '$4');
str = multiple(str, /(\£|(£))([\w \-\,®]*)\|(.*)$/, '$4');
// colors
str = multiple(str, /&#35;&#35;&#35;([\da-f]{6}|[\da-f]{3})(.+)$/i, '$2');
str = multiple(str, /&#35;&#35;([\da-f]{6}|[\da-f]{3})(.+)$/i, '$2');
str = multiple(str, /&#35;([\da-f]{6}|[\da-f]{3})(.+)$/i, '$2');
str = multiple(str, RegExp('&#35;&#35;&#35;(' + coloreg + ')(.+)$', 'i'), '$2');
str = multiple(str, RegExp('&#35;&#35;(' + coloreg + ')(.+)$', 'i'), '$2');
str = multiple(str, RegExp('&#35;(' + coloreg + ')(.+)$', 'i'), '$2');
// styles
str = multiple(str, /\/\%%([^\%%]+)\%%/g, '$1');
str = multiple(str, /\/\^([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\*([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\%([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\_([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\-([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\&#126;([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\&#35;([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\+([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\!([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\&#36;([^\|]+)\|?/g, '$1');
str = multiple(str, /\/\@([^\|]+)\|?/g, '$1');
return str;
}
*/
function randomByte() {
return Math.round(Math.random()*256);
}
function randomIp() {
var ip = randomByte() +'.' +
randomByte() +'.' +
randomByte() +'.' +
randomByte();
return ip;
}

View File

@ -44,8 +44,6 @@ dClient.once('ready', () => {
require('./commands.js');
require('./colorroles.js');
require('./mppbridger.js');
require('./owopbridge.js');
//require('./awakensbridge.js');
require('./screenshotter.js');
require('./misc.js');

View File

@ -1,108 +0,0 @@
var striptags = require('striptags');
function createOWOPbridge(dClient, channelID, webhookID, webhookToken, OWOPworld = 'main', OWOPnick = '[Discord]'){
var webhook = new Discord.WebhookClient(webhookID, webhookToken, {disableEveryone:true});
var WebSocket = require('ws');
var socket;
var canConnect = true;
function connect() {
if (!canConnect) return;
var myId;
socket = new WebSocket("ws://ourworldofpixels.com:443/");
socket.binaryType = "arraybuffer";
var pingInterval;
socket.addEventListener('open', () => {
console.log('[OWOP] ws open');
joinWorld(OWOPworld);
sendMessage('/nick '+OWOPnick);
pingInterval = setInterval(sendCursorActivity, 1000*60*5);
webhook.send('**Connected**');
});
socket.addEventListener('close', () => {
console.log('[OWOP] ws close');
clearInterval(pingInterval);
setTimeout(connect, 10000);
webhook.send('**Disconnected**');
});
socket.addEventListener('error', console.error);
socket.addEventListener('message', msg => {
if (!myId) myId = extractId(msg.data);
if (typeof msg.data != "string") return;
if (myId && (msg.data.startsWith(`[${myId}]`) || msg.data.startsWith(myId))) return;
webhook.send(striptags(msg.data));
});
} connect();
dClient.on('message', message => {
if (message.channel.id != channelID) return;
var str = `${message.member.displayName}: ${message.cleanContent}`;
if (message.attachments.first()) str += ' ' + message.attachments.first().url;
if (str.length > 128) str = str.substr(0,127) + '…';
sendMessage(str);
});
function joinWorld(name) {
var nstr = stoi(name, 24);
var array = new ArrayBuffer(nstr[0].length + 2);
var dv = new DataView(array);
for (var i = nstr[0].length; i--;) {
dv.setUint8(i, nstr[0][i]);
}
dv.setUint16(nstr[0].length, 1337, true);
socket.send(array);
return nstr[1];
}
function stoi(string, max) {
var ints = [];
var fstring = "";
string = string.toLowerCase();
for (var i = 0; i < string.length && i < max; i++) {
var charCode = string.charCodeAt(i);
if (charCode < 123 && charCode > 96 || charCode < 58 && charCode > 47 || charCode == 95 || charCode == 46) {
fstring += String.fromCharCode(charCode);
ints.push(charCode);
}
}
return [ints, fstring];
}
function sendMessage(str) {
if (socket && socket.readyState == WebSocket.OPEN)
socket.send(str + String.fromCharCode(10));
}
function sendCursorActivity() { // thx kit
var arb = new ArrayBuffer(12);
var dv = new DataView(arb);
dv.setInt32(0, 0, true); // x
dv.setInt32(4, 0, true); // y
dv.setUint8(8, 0); // r
dv.setUint8(9, 0); // g
dv.setUint8(10, 0); // b
dv.setUint8(11, "cursor"); // tool
socket.send(arb);
}
function extractId(arb) {
var dv = new DataView(arb);
var type = dv.getUint8(0);
if (type != 0) return null;
var _id = dv.getUint32(1, true);
webhook.send(`**ID is \`${_id}\`**`);
return _id;
}
return {
socket,
start: function(){canConnect = true; connect();},
stop: function(){canConnect = false; socket.close();}
}
}
global.createOWOPbridge = createOWOPbridge;
//global.OWOPbridge = createOWOPbridge(dClient, '398613291817238548', '398613329439883275', config.webhooks.owop);