2023-07-22 19:39:26 +00:00
|
|
|
|
const fs = require("fs");
|
|
|
|
|
const websocket = require("ws");
|
2024-11-24 10:18:05 +00:00
|
|
|
|
var irc = require("irc");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
const fetch = require("node-fetch");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
const formdata = require("form-data");
|
|
|
|
|
const he = require("he");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
const cheerio = require("cheerio");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var mmm = require("mmmagic");
|
|
|
|
|
var Magic = mmm.Magic;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-03 21:59:48 +00:00
|
|
|
|
var ws_logged_in = false;
|
|
|
|
|
|
2024-11-03 21:22:12 +00:00
|
|
|
|
const mineflayer = require("mineflayer");
|
2024-11-24 10:18:05 +00:00
|
|
|
|
const mc_bridge_enabled = false;
|
|
|
|
|
const irc_bridge_enabled = true;
|
|
|
|
|
const instance = "https://4get.lumaeris.com";
|
2024-11-08 05:19:01 +00:00
|
|
|
|
var scraper = "ddg";
|
2024-11-03 21:22:12 +00:00
|
|
|
|
|
|
|
|
|
const mc_options = {
|
|
|
|
|
"host": "deek.chat",
|
|
|
|
|
"port": 25565,
|
|
|
|
|
"username": "rena_chan"
|
|
|
|
|
// offline mode
|
|
|
|
|
};
|
|
|
|
|
|
2024-11-24 10:18:05 +00:00
|
|
|
|
const irc_ip = "192.168.0.152";
|
|
|
|
|
|
2023-11-24 04:41:04 +00:00
|
|
|
|
var http = require("http");
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
const emitter = require("events");
|
|
|
|
|
const deek = new emitter();
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
|
|
|
|
const name = "rena_chan";
|
2024-11-24 10:18:05 +00:00
|
|
|
|
const password = "no";
|
|
|
|
|
const irc_password = "no";
|
2023-07-22 19:39:26 +00:00
|
|
|
|
const userid = 12;
|
|
|
|
|
var channels = [];
|
|
|
|
|
var ws = [];
|
2024-08-08 02:40:40 +00:00
|
|
|
|
var results_cache = [];
|
|
|
|
|
var is_pp_xeno = false;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var ddg_mod = true; // dont show porn in .img
|
|
|
|
|
var global_page = 1; // .img page
|
|
|
|
|
var raid = false; // raid?
|
|
|
|
|
var img_headers = {
|
2024-09-07 01:51:27 +00:00
|
|
|
|
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:130.0) Gecko/20100101 Firefox/130.0",
|
2023-07-22 19:39:26 +00:00
|
|
|
|
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8",
|
|
|
|
|
"Accept-Language": "en-US,en;q=0.5",
|
|
|
|
|
"Accept-Encoding": "gzip, deflate",
|
|
|
|
|
"DNT": "1",
|
|
|
|
|
"Connection": "keep-alive"
|
|
|
|
|
};
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-10-06 01:59:50 +00:00
|
|
|
|
var fortunes = [
|
|
|
|
|
"You will meet a dark stranger.",
|
|
|
|
|
"You will be eaten by a grue.",
|
|
|
|
|
"Your fortune: Bad Luck.",
|
|
|
|
|
"Your fortune: Good Luck.",
|
|
|
|
|
"Your fortune: Reply hazy, try again.",
|
|
|
|
|
"Your fortune: Outlook not so good.",
|
|
|
|
|
"Your fortune: YES.",
|
|
|
|
|
"Your fortune: NO.",
|
|
|
|
|
"Your fortune: Absolutely.",
|
|
|
|
|
"Your fortune: Very doubtful.",
|
|
|
|
|
"Your fortune: Cannot predict now.",
|
|
|
|
|
"Your fortune: Signs point to yes.",
|
|
|
|
|
"Your fortune: Don't count on it.",
|
|
|
|
|
"Your fortune: You may rely on it.",
|
|
|
|
|
"Your fortune: Concentrate and ask again.",
|
2024-10-06 02:12:46 +00:00
|
|
|
|
"Your fortune: The future is uncertain.",
|
2024-10-27 18:40:41 +00:00
|
|
|
|
"Your fortune: it's over"
|
2024-10-06 01:59:50 +00:00
|
|
|
|
];
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var headers = {
|
2023-10-03 03:51:09 +00:00
|
|
|
|
"User-Agent": "renabot",
|
2024-03-31 01:04:47 +00:00
|
|
|
|
"Origin": "https://deek.chat"
|
2023-07-22 19:39:26 +00:00
|
|
|
|
};
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-04-07 04:47:22 +00:00
|
|
|
|
/*
|
2024-09-07 01:51:27 +00:00
|
|
|
|
HTTP server bullshit
|
2024-04-07 04:47:22 +00:00
|
|
|
|
*/
|
2024-11-03 21:22:12 +00:00
|
|
|
|
//process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0';
|
2024-10-31 00:35:31 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
const http_bullshit_handler = function(req, res){
|
|
|
|
|
|
|
|
|
|
switch(req.url){
|
2024-08-08 02:40:40 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
case "/":
|
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
|
res.writeHead(200);
|
|
|
|
|
res.end('<body style="color:#fff;background:#000;"><h1>all work and no play makes deek a dull boy</h1>');
|
|
|
|
|
break;
|
2024-04-07 04:47:22 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
case "/kys":
|
|
|
|
|
res.setHeader("Content-Type", "text/html");
|
|
|
|
|
res.writeHead(200);
|
|
|
|
|
res.end('<body style="color:red;background:#000;"><h1>bang!</h1>');
|
2024-08-08 02:40:40 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
send(1, "Resharted from web interface");
|
2024-04-07 04:47:22 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
setTimeout(function(){
|
2024-08-08 02:40:40 +00:00
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
fs.utimesSync(__filename, Date.now(), Date.now());
|
|
|
|
|
}, 1000);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
res.writeHead(404);
|
|
|
|
|
res.end("fuck you");
|
|
|
|
|
break;
|
2024-04-07 04:47:22 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2024-09-07 01:51:27 +00:00
|
|
|
|
const http_bullshit = http.createServer(http_bullshit_handler);
|
|
|
|
|
http_bullshit.listen(6969, "0.0.0.0", function(){
|
|
|
|
|
|
|
|
|
|
console.log("HTTP bullshit running");
|
|
|
|
|
});
|
2024-04-07 04:47:22 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
/*
|
|
|
|
|
Helper functions
|
|
|
|
|
*/
|
|
|
|
|
async function getmime(file){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
return new Promise(function(resolve, reject){
|
|
|
|
|
|
|
|
|
|
var magic = new Magic(mmm.MAGIC_MIME_TYPE);
|
|
|
|
|
magic.detect(file, function(err, result){
|
|
|
|
|
|
|
|
|
|
if(err){
|
|
|
|
|
|
|
|
|
|
resolve([
|
|
|
|
|
"image/png",
|
|
|
|
|
"png",
|
|
|
|
|
false
|
|
|
|
|
]);
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
resolve([
|
|
|
|
|
result,
|
|
|
|
|
result.split("/")[1],
|
|
|
|
|
true
|
|
|
|
|
]);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
function removehtml(html){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
return he.decode(html.replace(/<[^>]+>/ig,""));
|
|
|
|
|
};
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
async function serveddg(msg, results, page){
|
|
|
|
|
|
|
|
|
|
page--;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
var res = await fetch(
|
2024-11-08 05:19:01 +00:00
|
|
|
|
results[page].source[0].url,
|
2024-03-31 01:04:47 +00:00
|
|
|
|
{
|
|
|
|
|
headers: img_headers,
|
|
|
|
|
signal: AbortSignal.timeout(3000)
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
);
|
2024-10-27 18:40:41 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var res_get = await res.buffer();
|
|
|
|
|
var m = await getmime(res_get);
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
m[2] === false ||
|
|
|
|
|
m[0].split("/")[0] != "image"
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
var res = await fetch(
|
2024-11-08 05:19:01 +00:00
|
|
|
|
results[page].source[results[page].source.length - 1].url,
|
2024-03-31 01:04:47 +00:00
|
|
|
|
{
|
|
|
|
|
headers: img_headers,
|
|
|
|
|
signal: AbortSignal.timeout(5000)
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var res_get = await res.buffer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}catch(err){
|
|
|
|
|
|
|
|
|
|
var res = await fetch(
|
2024-11-08 05:19:01 +00:00
|
|
|
|
results[page].source[results[page].source.length - 1].url,
|
2024-03-31 01:04:47 +00:00
|
|
|
|
{
|
|
|
|
|
headers: img_headers,
|
|
|
|
|
signal: AbortSignal.timeout(5000)
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var res_get = await res.buffer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
2024-11-24 10:18:05 +00:00
|
|
|
|
"Page " + (page + 1) + "/" + (results.length) + "\n[" + results[page].source[0].width + "x" + results[page].source[0].height + "] " + results[page].title + "\n" + results[page].url,
|
2023-07-22 19:39:26 +00:00
|
|
|
|
res_get
|
|
|
|
|
);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
/*
|
|
|
|
|
Websocket functions
|
|
|
|
|
*/
|
2023-11-25 00:00:50 +00:00
|
|
|
|
async function send(channel, text, file = null, forcemime = null){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-03 21:59:48 +00:00
|
|
|
|
if(ws_logged_in === false){ return; }
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(typeof channel == "object"){
|
|
|
|
|
|
|
|
|
|
channel = channel.channel;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(file === null){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
ws.send(JSON.stringify({
|
2023-07-22 19:39:26 +00:00
|
|
|
|
type: "messageEnd",
|
2023-10-03 03:51:09 +00:00
|
|
|
|
data: text,
|
|
|
|
|
roomId: channel
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}));
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
/*
|
|
|
|
|
Send file
|
|
|
|
|
*/
|
2023-11-25 00:00:50 +00:00
|
|
|
|
if(forcemime === null){
|
|
|
|
|
|
|
|
|
|
var mimetype = await getmime(file);
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
var mimetype = forcemime;
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
var form_data = new formdata();
|
|
|
|
|
form_data.append("text", text);
|
|
|
|
|
form_data.append(
|
|
|
|
|
"files[]",
|
|
|
|
|
file,
|
|
|
|
|
{
|
|
|
|
|
contentType: mimetype[0],
|
|
|
|
|
name: "file",
|
|
|
|
|
filename: "file." + mimetype[1]
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var headers_copy = headers;
|
|
|
|
|
headers_copy["Content-Type"] = form_data.getHeaders()["content-type"];
|
|
|
|
|
|
|
|
|
|
fetch("https://deek.chat/message/send/" + channel, {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
body: form_data,
|
|
|
|
|
headers: headers_copy
|
2024-04-07 04:47:22 +00:00
|
|
|
|
});
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Handshake
|
|
|
|
|
*/
|
2024-11-03 21:59:48 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
async function handshake(name, password){
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Get cookie
|
|
|
|
|
*/
|
|
|
|
|
console.log("logging in as " + name);
|
|
|
|
|
|
|
|
|
|
const form = new formdata();
|
|
|
|
|
|
|
|
|
|
form.append("name", name);
|
|
|
|
|
form.append("password", password);
|
|
|
|
|
form.append("submit", "log+in");
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
var login = await fetch(
|
|
|
|
|
"https://deek.chat/login/submit",
|
|
|
|
|
{
|
|
|
|
|
method: "POST",
|
|
|
|
|
redirect: "manual",
|
|
|
|
|
body: form,
|
|
|
|
|
headers: headers
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}catch(err){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
console.log("Could not login. Trying again in 10 seconds...");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
setTimeout(function(){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
fs.utimesSync(__filename, Date.now(), Date.now());
|
|
|
|
|
}, 10000);
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var cookie = await login.headers.get("set-cookie");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var api_token = cookie.match(/api_token=([^;]+)/);
|
|
|
|
|
var session_id = cookie.match(/session_id=([^;]+)/);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(
|
2023-11-24 04:41:04 +00:00
|
|
|
|
api_token === null ||
|
2023-07-22 19:39:26 +00:00
|
|
|
|
typeof api_token[1] != "string" ||
|
|
|
|
|
typeof session_id[1] != "string"
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
deek.emit("error", "Could not get api_token or session_id !!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
headers.cookie = "session_id=" + session_id[1] + "; api_token=" + api_token[1];
|
|
|
|
|
|
|
|
|
|
/*
|
2023-10-03 03:51:09 +00:00
|
|
|
|
Connect to websocket serber
|
2023-07-22 19:39:26 +00:00
|
|
|
|
*/
|
2023-10-03 03:51:09 +00:00
|
|
|
|
ws = new websocket(
|
|
|
|
|
"wss://deek.chat/ws",
|
2023-07-22 19:39:26 +00:00
|
|
|
|
{
|
2023-10-03 03:51:09 +00:00
|
|
|
|
protocolVersion: 13,
|
|
|
|
|
encoding: "utf8",
|
2023-07-22 19:39:26 +00:00
|
|
|
|
headers: headers
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
2024-11-03 21:22:12 +00:00
|
|
|
|
var pong_time = Date.now();
|
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
ws.once("open", function(){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-03 21:59:48 +00:00
|
|
|
|
ws_logged_in = true;
|
2023-10-03 03:51:09 +00:00
|
|
|
|
deek.emit("login");
|
2024-11-03 06:22:12 +00:00
|
|
|
|
|
|
|
|
|
const keep_alive = setInterval(function(){
|
|
|
|
|
|
2024-11-03 21:22:12 +00:00
|
|
|
|
//console.log("ping!");
|
|
|
|
|
if(pong_time + 10000 < Date.now()){
|
|
|
|
|
|
|
|
|
|
deek.emit("error", "Did not receive ping frame");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-11-03 06:22:12 +00:00
|
|
|
|
ws.ping();
|
2024-11-03 21:22:12 +00:00
|
|
|
|
|
2024-11-03 06:22:12 +00:00
|
|
|
|
}, 5000);
|
2023-10-03 03:51:09 +00:00
|
|
|
|
});
|
2024-11-03 21:22:12 +00:00
|
|
|
|
|
|
|
|
|
ws.on("pong", function(){
|
|
|
|
|
|
|
|
|
|
pong_time = Date.now();
|
|
|
|
|
//console.log(pong_time + ": pong!");
|
|
|
|
|
});
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
ws.once("close", function(){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2024-11-03 21:59:48 +00:00
|
|
|
|
ws_logged_in = false;
|
2023-10-03 03:51:09 +00:00
|
|
|
|
deek.emit("close");
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
ws.on("message", function(message, isbin){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
if(isbin){ return; }
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
var m = JSON.parse(message.toString("utf8"));
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
if(typeof m.type == "undefined"){
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
switch(m.type){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-11-24 04:41:04 +00:00
|
|
|
|
case "message":
|
2023-10-03 03:51:09 +00:00
|
|
|
|
case "messageEnd":
|
|
|
|
|
for(var k=0; k<m.data.mentions.length; k++){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
m.data.mentions[k].id = m.data.mentions[k].userId;
|
|
|
|
|
delete m.data.mentions[k].userId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for(var k=0; k<m.data.replies.length; k++){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
m.data.replies[k].id = m.data.replies[k].userId;
|
|
|
|
|
m.data.replies[k] = m.data.replies[k].replyMessageId;
|
|
|
|
|
delete m.data.replies[k].userId;
|
|
|
|
|
delete m.data.replies[k].replyMessageId;
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
m.data.files = m.data.files === null ? [] : m.data.files;
|
|
|
|
|
var files = [];
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
for(var k=0; k<m.data.files.length; k++){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
files.push("https://deek.chat/storage/files/" + m.data.files[k].name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deek.emit(
|
|
|
|
|
"message",
|
|
|
|
|
{
|
|
|
|
|
text: removehtml(m.data.text),
|
|
|
|
|
id: m.data.id,
|
|
|
|
|
files: files,
|
|
|
|
|
mentions: m.data.mentions,
|
|
|
|
|
replies: m.data.replies,
|
|
|
|
|
channel: m.roomId
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: m.data.name,
|
|
|
|
|
id: m.userId,
|
|
|
|
|
picture: m.data.profilePicture == "" ? null : "https://deek.chat/storage/profilePictures/" + m.data.profilePicture
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
2023-10-03 03:51:09 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "files":
|
2023-11-24 04:41:04 +00:00
|
|
|
|
var files = [];
|
2023-10-03 03:51:09 +00:00
|
|
|
|
|
2023-11-24 04:41:04 +00:00
|
|
|
|
if(m.data.files !== null){
|
|
|
|
|
for(var k=0; k<m.data.files.length; k++){
|
|
|
|
|
|
|
|
|
|
files.push("https://deek.chat/storage/files/" + m.data.files[k].name);
|
|
|
|
|
}
|
2023-10-03 03:51:09 +00:00
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
deek.emit(
|
|
|
|
|
"message",
|
|
|
|
|
{
|
|
|
|
|
text: removehtml(m.data.text),
|
|
|
|
|
id: m.data.id,
|
|
|
|
|
files: files,
|
|
|
|
|
mentions: m.data.mentions,
|
|
|
|
|
replies: m.data.replies,
|
|
|
|
|
channel: m.roomId
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: m.data.name,
|
2023-11-24 04:41:04 +00:00
|
|
|
|
id: m.data.userId,
|
|
|
|
|
picture: m.data.profilePicture == "" ? null : "https://deek.chat/storage/profilePictures/" + m.data.profilePicture
|
2023-10-03 03:51:09 +00:00
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
//console.warn(m);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
2024-11-03 05:24:44 +00:00
|
|
|
|
|
2024-11-03 05:49:02 +00:00
|
|
|
|
ws.on("error", function(code, reason){
|
2024-11-03 05:24:44 +00:00
|
|
|
|
|
2024-11-03 21:59:48 +00:00
|
|
|
|
ws_logged_in = false;
|
2024-11-03 05:24:44 +00:00
|
|
|
|
deek.emit("error", "code=" + code + " reason=" + reason);
|
|
|
|
|
});
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-11-03 21:22:12 +00:00
|
|
|
|
/*
|
|
|
|
|
Mineflayer bot code
|
|
|
|
|
*/
|
|
|
|
|
var mc_logged_in = false;
|
|
|
|
|
var mc_bot = null;
|
|
|
|
|
|
|
|
|
|
function mc_login(){
|
|
|
|
|
|
|
|
|
|
if(mc_bridge_enabled === false){ return; }
|
|
|
|
|
|
|
|
|
|
mc_bot = mineflayer.createBot(mc_options);
|
|
|
|
|
|
|
|
|
|
mc_bot.once("login", function(){
|
|
|
|
|
|
|
|
|
|
console.log("Logged into minecraft server as " + mc_options.username);
|
|
|
|
|
mc_logged_in = true;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mc_bot.on("chat", function(username, message){
|
|
|
|
|
|
|
|
|
|
if(username !== mc_bot.username){
|
|
|
|
|
|
|
|
|
|
send(1, "<" + username + "> " + message);
|
|
|
|
|
}
|
2024-11-03 22:55:21 +00:00
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
username === "4lul" &&
|
|
|
|
|
message.startsWith(".run")
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
var cmd = message.split(" ");
|
|
|
|
|
cmd.shift();
|
|
|
|
|
cmd = cmd.join(" ");
|
|
|
|
|
mc_bot.chat(cmd);
|
2024-11-06 04:32:50 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(message.startsWith("rena take me home")){
|
|
|
|
|
|
|
|
|
|
mc_bot.chat("/tp " + username + " rena_chan");
|
|
|
|
|
mc_bot.chat("I will take you home! <3");
|
2024-11-03 22:55:21 +00:00
|
|
|
|
}
|
2024-11-03 21:22:12 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mc_bot.on("end", function(){
|
|
|
|
|
|
|
|
|
|
mc_logged_in = false;
|
|
|
|
|
console.log("Minecraft: Kicked from server");
|
2024-11-04 14:51:47 +00:00
|
|
|
|
setTimeout(mc_login, 10000); // reconnect after 10 seconds
|
2024-11-03 21:22:12 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
mc_bot.on("error", function(){
|
|
|
|
|
|
2024-11-03 21:50:26 +00:00
|
|
|
|
console.log("Minecraft: error occured");
|
2024-11-03 21:22:12 +00:00
|
|
|
|
});
|
2024-11-03 21:50:26 +00:00
|
|
|
|
|
|
|
|
|
mc_bot.on("playerJoined", function(player){
|
|
|
|
|
|
|
|
|
|
send(1, ">" + player.username + " has joined deekcraft");
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
mc_bot.on("playerLeft", function(player){
|
|
|
|
|
|
|
|
|
|
send(1, ">" + player.username + " has left deekcraft");
|
|
|
|
|
})
|
2024-11-03 21:22:12 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
mc_login();
|
|
|
|
|
|
|
|
|
|
function mc_escape(str){
|
|
|
|
|
|
|
|
|
|
return str.replace(
|
|
|
|
|
/[^-!\"#$%&'()*+,.\/0123456789:;<=>?@[\\\]^_'abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«» ]/gi,
|
|
|
|
|
""
|
|
|
|
|
).replace(/[\\"']/g, '\\$&')
|
|
|
|
|
.replace(/\u0000/g, '\\0')
|
|
|
|
|
.replace("\n", " ");
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-24 10:18:05 +00:00
|
|
|
|
/*
|
|
|
|
|
IRC bridge
|
|
|
|
|
*/
|
|
|
|
|
var irc_logged_in = false;
|
|
|
|
|
var irc_debounce = false;
|
|
|
|
|
var irc_client = null;
|
|
|
|
|
|
|
|
|
|
function init_irc(){
|
|
|
|
|
if(irc_bridge_enabled === false){
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
irc_client =
|
|
|
|
|
new irc.Client(
|
|
|
|
|
irc_ip,
|
|
|
|
|
"rena_chan",
|
|
|
|
|
{
|
|
|
|
|
channels: [
|
|
|
|
|
"#deekchat"
|
|
|
|
|
],
|
|
|
|
|
userName: "rena_chan",
|
|
|
|
|
realName: "Rena Chan",
|
|
|
|
|
autoRejoin: false,
|
|
|
|
|
retryCount: 0
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
irc_client.addListener("join#deekchat", function(){
|
|
|
|
|
|
|
|
|
|
console.log("Connected to IRC server on #deekchat");
|
|
|
|
|
irc_logged_in = true;
|
|
|
|
|
|
|
|
|
|
irc_client.say("NickServ", "IDENTIFY rena_chan " + irc_password);
|
|
|
|
|
irc_client.send("OPER", "rena_chan", irc_password);
|
|
|
|
|
|
|
|
|
|
// add debounce so we dont send missed messages
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
|
|
|
|
|
irc_debounce = true;
|
|
|
|
|
}, 2500);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
irc_client.addListener("message", function(from, to, message){
|
|
|
|
|
|
|
|
|
|
if(irc_debounce === false){ return; }
|
|
|
|
|
|
|
|
|
|
if(typeof from == "undefined"){ return; }
|
|
|
|
|
|
|
|
|
|
switch(to){
|
|
|
|
|
|
|
|
|
|
case "#deekchat":
|
|
|
|
|
send(1, "<" + from + "> " + message);
|
2024-11-24 22:47:20 +00:00
|
|
|
|
|
|
|
|
|
deek.emit(
|
|
|
|
|
"message",
|
|
|
|
|
{
|
|
|
|
|
text: message,
|
|
|
|
|
id: -1,
|
|
|
|
|
files: [],
|
|
|
|
|
mentions: [],
|
|
|
|
|
replies: [],
|
|
|
|
|
channel: 1
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: from,
|
|
|
|
|
id: -1,
|
|
|
|
|
picture: null
|
|
|
|
|
}
|
|
|
|
|
);
|
2024-11-24 10:18:05 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
irc_client.addListener("error", function(message){
|
|
|
|
|
|
|
|
|
|
console.log("IRC error");
|
|
|
|
|
console.log(message);
|
|
|
|
|
|
|
|
|
|
irc_logged_in = false;
|
|
|
|
|
irc_debounce = false;
|
2024-11-24 22:47:20 +00:00
|
|
|
|
//irc_client.disconnect();
|
2024-11-24 10:18:05 +00:00
|
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
|
|
|
|
|
init_irc();
|
|
|
|
|
}, 2000);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
init_irc();
|
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
/*
|
|
|
|
|
User defined FUN-ctions!!!
|
|
|
|
|
*/
|
|
|
|
|
async function fetch_xeno(recording, index, msg){
|
|
|
|
|
|
|
|
|
|
index--;
|
|
|
|
|
|
|
|
|
|
var filereq = await fetch(
|
|
|
|
|
recording[index].file,
|
|
|
|
|
{headers: img_headers}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var file = await filereq.buffer();
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"Page " + (index + 1) + "/" + recording.length + "\n" +
|
|
|
|
|
">" + recording[index].en + " in " + recording[index].cnt + " (" + recording[index].loc + ")\n" +
|
|
|
|
|
recording[index].rmk,
|
|
|
|
|
file,
|
|
|
|
|
[
|
|
|
|
|
"audio/mpeg",
|
|
|
|
|
"mp3"
|
|
|
|
|
]
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
deek.on("login", function(channel){
|
|
|
|
|
|
|
|
|
|
console.log("Connected to websocket xoxo");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
deek.on("message", async function(msg, user){
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
(
|
2023-11-24 04:41:04 +00:00
|
|
|
|
user.id === 13 || // me lol
|
|
|
|
|
user.id === 14 || // aves
|
|
|
|
|
user.id === 8 || // aves again
|
|
|
|
|
user.id === 30 || // eagle
|
|
|
|
|
user.id === 2 || // deek
|
2023-07-22 19:39:26 +00:00
|
|
|
|
raid === false
|
|
|
|
|
) === false
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
user.id === userid ||
|
|
|
|
|
user.name == name
|
|
|
|
|
){
|
|
|
|
|
return;
|
|
|
|
|
}
|
2024-03-31 01:04:47 +00:00
|
|
|
|
/*
|
2023-11-24 04:41:04 +00:00
|
|
|
|
if(user.id === 5311){
|
|
|
|
|
|
|
|
|
|
user.name = msg.text.split(">")[0].substr(1);
|
|
|
|
|
msg.text = msg.text.split(">").splice(1).join(">").trim();
|
2024-03-31 01:04:47 +00:00
|
|
|
|
}*/
|
2023-11-24 04:41:04 +00:00
|
|
|
|
|
2024-11-03 21:22:12 +00:00
|
|
|
|
if(
|
|
|
|
|
mc_bridge_enabled &&
|
2024-11-04 14:51:47 +00:00
|
|
|
|
mc_logged_in &&
|
|
|
|
|
msg.channel === 1
|
2024-11-03 21:22:12 +00:00
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
// ascii filter
|
|
|
|
|
var mc_message = msg.text.replace(
|
2024-11-04 14:51:47 +00:00
|
|
|
|
/[^-\n!\"#$%&'()*+,.\/0123456789:;<=>?@[\\\]^_'abcdefghijklmnopqrstuvwxyz{|}~⌂ÇüéâäàåçêëèïîìÄÅÉæÆôöòûùÿÖÜø£Ø׃áíóúñѪº¿®¬½¼¡«» ]/gi,
|
2024-11-03 21:22:12 +00:00
|
|
|
|
"?"
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var mc_username = mc_escape(user.name);
|
|
|
|
|
|
|
|
|
|
mc_message.split("\n").forEach(function(a){
|
|
|
|
|
|
|
|
|
|
// split message into newlines
|
|
|
|
|
// make sure message gets sent in chunks
|
|
|
|
|
|
|
|
|
|
for(var i=0; i<a.length; i += 100){
|
|
|
|
|
|
|
|
|
|
if(i === 0){
|
|
|
|
|
|
|
|
|
|
mc_bot.chat('/tellraw @a ["<",{"text":"' + mc_username + '","color":"gold"},"> ' + mc_escape(a.slice(i, i + 100)).trim() + '"]');
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
mc_bot.chat('/tellraw @a "' + mc_escape(a.slice(i, i + 100)) + '"');
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2024-11-24 10:18:05 +00:00
|
|
|
|
if(
|
|
|
|
|
irc_bridge_enabled &&
|
|
|
|
|
irc_logged_in &&
|
2024-11-24 22:47:20 +00:00
|
|
|
|
msg.channel === 1 &&
|
|
|
|
|
msg.id !== -1
|
2024-11-24 10:18:05 +00:00
|
|
|
|
){
|
|
|
|
|
|
2024-11-24 22:47:20 +00:00
|
|
|
|
var irc_username = user.name.replace(/[^A-Za-z0-9-_]/g, "-");
|
|
|
|
|
var limit = 412 - ("RELAYMSG #deekchat " + irc_username + "/Dek").length;
|
|
|
|
|
|
2024-11-24 10:18:05 +00:00
|
|
|
|
msg.text.split("\n").forEach(function(a){
|
|
|
|
|
|
|
|
|
|
for(var i=0; i<a.length; i += limit){
|
|
|
|
|
|
2024-11-24 22:47:20 +00:00
|
|
|
|
irc_client.send("RELAYMSG", "#deekchat", irc_username + "/Dek", a.slice(i, i + limit));
|
2024-11-24 10:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
for(var i=0; i<msg.files.length; i++){
|
|
|
|
|
|
2024-11-24 22:47:20 +00:00
|
|
|
|
irc_client.send("RELAYMSG", "#deekchat", irc_username + "/Dek", msg.files[i]);
|
2024-11-24 10:18:05 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
switch(msg.text.toLowerCase()){
|
|
|
|
|
|
|
|
|
|
case "hello rena":
|
|
|
|
|
case "hi rena":
|
|
|
|
|
case "what's up rena":
|
|
|
|
|
case "whats up rena":
|
|
|
|
|
send(msg, "hi " + user.name);
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case "/help":
|
|
|
|
|
send(msg, "lmao newfag");
|
2024-03-31 01:04:47 +00:00
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
case "fuck you rena":
|
|
|
|
|
send(msg, "fuck you eagle");
|
|
|
|
|
return;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
shitty embed support
|
|
|
|
|
*/
|
|
|
|
|
if(link = msg.text.match(/https?:\/\/[^ \n\r'>]+/)){
|
|
|
|
|
|
|
|
|
|
link = link[0];
|
2024-10-27 18:40:41 +00:00
|
|
|
|
var download = null;
|
|
|
|
|
var mimetype = null;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
2024-10-27 18:40:41 +00:00
|
|
|
|
if(tweet = link.match(/https?:\/\/(?:www\.)?(?:twitter|x)\.com\/[A-Za-z0-9_]+\/status\/([0-9]+)/i)){
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
// twitter embed
|
|
|
|
|
//
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
tweet = tweet[1];
|
2024-10-27 18:40:41 +00:00
|
|
|
|
var res = await fetch("https://cdn.syndication.twimg.com/tweet-result?id=" + tweet + "&token=5");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var json = await res.json();
|
|
|
|
|
|
|
|
|
|
var title = json.user.name + " (@" + json.user.screen_name + ") " + " on twatter";
|
2024-10-27 18:40:41 +00:00
|
|
|
|
var description = "❤️ " + json.favorite_count + " • 💬 " + json.conversation_count + " • 📅 " + json.created_at + "\n" + json.text + " ";
|
|
|
|
|
|
|
|
|
|
if(typeof json.video == "object"){
|
|
|
|
|
|
|
|
|
|
download = json.video.variants[json.video.variants.length - 1].src;
|
|
|
|
|
mimetype = ["video/mp4", "mp4", true];
|
|
|
|
|
}else if(typeof json.photos[0].url == "string"){
|
|
|
|
|
|
|
|
|
|
download = json.photos[0].url;
|
|
|
|
|
mimetype = ["image/jpeg", "jpeg", true];
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2024-03-31 02:01:54 +00:00
|
|
|
|
}else if(watch = link.match(/(?:youtube\.com\/(?:[^\/]+\/.+\/|(?:v|e(?:mbed)?)\/|.*[?&]v=)|youtu\.be\/)([^"&?\/\s]{11})/i)){
|
|
|
|
|
|
|
|
|
|
watch = watch[1];
|
|
|
|
|
var res = await fetch("https://youtube.com/oembed?url=/watch?v=" + watch);
|
|
|
|
|
var json = await res.json();
|
|
|
|
|
|
|
|
|
|
var title = json.title;
|
|
|
|
|
var description = "By " + json.author_name;
|
|
|
|
|
|
2024-10-31 00:35:31 +00:00
|
|
|
|
}else if(bsky = link.match(/https?:\/\/bsky\.app\/profile\/([^\/]+)\/post\/([^?]+)/)){
|
|
|
|
|
|
|
|
|
|
var bsky_profile = bsky[1];
|
|
|
|
|
var bsky_post = bsky[2];
|
|
|
|
|
|
|
|
|
|
if(!bsky_profile.match(/^did:plc:/)){
|
|
|
|
|
|
|
|
|
|
// resolve handle
|
|
|
|
|
var handle = await(fetch("https://public.api.bsky.app/xrpc/com.atproto.identity.resolveHandle?handle=" + bsky_profile));
|
|
|
|
|
var handle_json = await handle.json();
|
|
|
|
|
bsky_profile = handle_json.did;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var res =
|
|
|
|
|
await(
|
|
|
|
|
fetch(
|
|
|
|
|
"https://public.api.bsky.app/xrpc/app.bsky.feed.getPostThread" +
|
|
|
|
|
"?uri=" + encodeURIComponent("at://" + bsky_profile + "/app.bsky.feed.post/" + bsky_post) +
|
|
|
|
|
//"?uri=at%3A%2F%2Fdid%3Aplc%3Aknkltoiapkt336rr335ztt3p%2Fapp.bsky.feed.post%2F3l3gymllsto2z" +
|
|
|
|
|
"&depth=0" +
|
|
|
|
|
"&parentHeight=0"
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var json = await res.json();
|
|
|
|
|
|
|
|
|
|
var title = json.thread.post.author.displayName + " (@" + json.thread.post.author.handle + ") " + " on blueskeet";
|
|
|
|
|
var description = "❤️ " + json.thread.post.likeCount + " • 💬 " + json.thread.post.replyCount + " • 📅 " + json.thread.post.indexedAt + "\n" + json.thread.post.record.text + " ";
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
typeof json.thread.post.embed == "object" &&
|
|
|
|
|
typeof json.thread.post.embed.images == "object" &&
|
|
|
|
|
typeof json.thread.post.embed.images[0] == "object" &&
|
|
|
|
|
typeof json.thread.post.embed.images[0].fullsize == "string"
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
// found image
|
|
|
|
|
download = json.thread.post.embed.images[0].fullsize;
|
|
|
|
|
mimetype = ["image/jpeg", "jpeg", true];
|
|
|
|
|
}
|
|
|
|
|
else if(
|
|
|
|
|
typeof json.thread.post.embed == "object" &&
|
|
|
|
|
typeof json.thread.post.embed.thumbnail == "string"
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
// no video support, fuck you bsky for not giving me mp4 files
|
|
|
|
|
download = json.thread.post.embed.thumbnail;
|
|
|
|
|
mimetype = ["image/jpeg", "jpeg", true];
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
var res = await fetch(
|
|
|
|
|
link,
|
2024-03-31 01:04:47 +00:00
|
|
|
|
{
|
|
|
|
|
headers: img_headers,
|
|
|
|
|
signal: AbortSignal.timeout(5000)
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var headers_arr = [...res.headers];
|
|
|
|
|
var headers = [];
|
|
|
|
|
|
|
|
|
|
for(i=0; i<headers_arr.length; i++){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
headers[headers_arr[i][0]] = headers_arr[i][1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
!headers["content-type"] ||
|
|
|
|
|
headers["content-type"].split(";")[0] != "text/html" ||
|
|
|
|
|
(
|
|
|
|
|
!headers["content-length"] &&
|
|
|
|
|
parseInt(headers["content-length"]) > 10485760 // 10MB
|
|
|
|
|
)
|
|
|
|
|
){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var text = "This thingy^ ";
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(headers["content-type"]){
|
|
|
|
|
|
|
|
|
|
var format = headers["content-type"].split("/");
|
|
|
|
|
format = format[format.length - 1].split(";")[0];
|
|
|
|
|
|
|
|
|
|
text += "is a " + format + " file ";
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
text += "is uhh... something.. err.. "
|
|
|
|
|
}
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(headers["content-length"]){
|
|
|
|
|
var filesize = Math.round(parseInt(headers["content-length"]) / 1048576);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
text += "that weighs " + (Math.round(parseInt(headers["content-length"]) / 1048576)) + "MB!!";
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
text += "that uhh weighs something probably idk!!!";
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
text += " lol thats all i know fuck you";
|
|
|
|
|
|
|
|
|
|
send(msg, text);
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
// cancerous code ahead
|
|
|
|
|
|
|
|
|
|
var buffer = await res.buffer();
|
|
|
|
|
|
|
|
|
|
const parser = cheerio.load(buffer);
|
|
|
|
|
|
|
|
|
|
// get title
|
|
|
|
|
var title = "Unknown title lol, shit website";
|
|
|
|
|
var tag_title = parser("title");
|
|
|
|
|
var tag_name_og_title = parser("meta[name='og:title']");
|
|
|
|
|
var tag_property_og_title = parser("meta[property='og:title']");
|
|
|
|
|
|
|
|
|
|
if(tag_name_og_title.length !== 0){ title = tag_name_og_title.attr("content"); }
|
|
|
|
|
if(tag_property_og_title.length !== 0){ title = tag_property_og_title.attr("content"); }
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(tag_title.length !== 0){ title = tag_title.text(); }
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// get description
|
|
|
|
|
var description = "Unknown description lol, stupid website do not click";
|
|
|
|
|
var tag_name_description = parser("meta[name='description']");
|
|
|
|
|
var tag_name_og_description = parser("meta[name='og:description']");
|
|
|
|
|
var tag_property_description = parser("meta[property='description']");
|
|
|
|
|
var tag_property_og_description = parser("meta[property='og:description']");
|
|
|
|
|
|
|
|
|
|
if(typeof tag_name_description.attr("content") != "undefined"){description = tag_name_description.attr("content"); }
|
|
|
|
|
if(typeof tag_name_og_description.attr("content") != "undefined"){description = tag_name_og_description.attr("content"); }
|
|
|
|
|
if(typeof tag_property_description.attr("content") != "undefined"){description = tag_property_description.attr("content"); }
|
|
|
|
|
if(typeof tag_property_og_description.attr("content") != "undefined"){description = tag_property_og_description.attr("content"); }
|
|
|
|
|
|
|
|
|
|
if(typeof tag_name_description.attr("value") != "undefined"){description = tag_name_description.attr("value"); }
|
|
|
|
|
if(typeof tag_name_og_description.attr("value") != "undefined"){description = tag_name_og_description.attr("value"); }
|
|
|
|
|
if(typeof tag_property_description.attr("value") != "undefined"){description = tag_property_description.attr("value"); }
|
|
|
|
|
if(typeof tag_property_og_description.attr("value") != "undefined"){description = tag_property_og_description.attr("value"); }
|
|
|
|
|
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var text = "";
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
description = description.split("\n");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
for(var i=0; i<description.length; i++){
|
|
|
|
|
|
|
|
|
|
text += "\n>" + description[i];
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-10-27 18:40:41 +00:00
|
|
|
|
if(download !== null){
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
|
|
|
|
|
var image = await fetch(
|
|
|
|
|
download,
|
|
|
|
|
{
|
|
|
|
|
headers: img_headers,
|
|
|
|
|
signal: AbortSignal.timeout(3000)
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
var download = await image.buffer();
|
|
|
|
|
|
|
|
|
|
}catch(err){
|
|
|
|
|
|
|
|
|
|
download = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send(msg, title + text, download, mimetype);
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}catch(err){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
send(msg, "Stupid retarded website alert!!!! I got an error accessing this shit...\n>" + err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
Commands
|
|
|
|
|
*/
|
|
|
|
|
var regex = msg.text.match(/^\.([^ ]+)(?: (.*))?/);
|
|
|
|
|
|
|
|
|
|
if(
|
|
|
|
|
regex === null ||
|
|
|
|
|
typeof regex[1] == "undefined"
|
|
|
|
|
){
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var cmd = regex[1];
|
|
|
|
|
|
|
|
|
|
if(typeof regex[2] != "undefined"){
|
|
|
|
|
var value = regex[2];
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
var value = "";
|
|
|
|
|
}
|
|
|
|
|
|
2023-11-24 04:41:04 +00:00
|
|
|
|
switch(cmd.toLowerCase()){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
case "raid":
|
2023-11-24 04:41:04 +00:00
|
|
|
|
if(
|
|
|
|
|
(
|
|
|
|
|
user.id === 13 || // me lol
|
2024-04-07 04:47:22 +00:00
|
|
|
|
user.id === 14 || // aves
|
|
|
|
|
user.id === 8 || // aves again
|
|
|
|
|
user.id === 30 || // eagle
|
2023-11-24 04:41:04 +00:00
|
|
|
|
user.id === 2 // deek
|
|
|
|
|
) === false
|
|
|
|
|
){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(raid === false){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
raid = true;
|
|
|
|
|
send(msg, "Ignoring all messages from now on, fuck you lol!!");
|
|
|
|
|
}else{
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
raid = false;
|
|
|
|
|
send(msg, "Now listening to messages!!!");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "rc":
|
|
|
|
|
case "reconnect":
|
|
|
|
|
if(user.id !== 13){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send(msg, "brb");
|
|
|
|
|
|
|
|
|
|
setTimeout(function(){
|
|
|
|
|
|
|
|
|
|
fs.utimesSync(__filename, Date.now(), Date.now());
|
|
|
|
|
}, 1000);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "ping":
|
|
|
|
|
send(msg, "Pong!!!!");
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "dice":
|
|
|
|
|
case "roll":
|
|
|
|
|
case "d":
|
|
|
|
|
case "r":
|
|
|
|
|
value = parseInt(value);
|
|
|
|
|
if(isNaN(value)){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
value = 6;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
if(value <= 1){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"Rolling a " + value + " faced dice...\nWait what?? " +
|
|
|
|
|
"You fucking shit, a black hole just appeared!!!!!! Oh my fucking shit!!!!!"
|
|
|
|
|
);
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"Rolling a " + value + " faced dice...\nAnd you got " +
|
|
|
|
|
(
|
|
|
|
|
Math.floor(Math.random() * value + 1)
|
|
|
|
|
) + "!!!"
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "mumble":
|
|
|
|
|
case "m":
|
|
|
|
|
var port = 64738;
|
|
|
|
|
|
|
|
|
|
if(value == ""){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var ip = "lolcat.ca";
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
|
|
var value = value.split(":");
|
|
|
|
|
|
|
|
|
|
if(value.length >= 2){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var port = value[1];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var ip = value[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try{
|
|
|
|
|
var res = await fetch("https://lolcat.ca/api/mumble/?ip=" + ip + "&port=" + port);
|
|
|
|
|
var res_get = await res.json();
|
|
|
|
|
|
|
|
|
|
if(res_get.status != "ok"){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
send(msg, "An error occured... " + res_get.status);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
res_get = res_get.server;
|
|
|
|
|
|
|
|
|
|
var servername = res_get.name === null ? res_get.domains[0] : res_get.name;
|
|
|
|
|
var website = res_get.website === null ? "No website available" : res_get.website;
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
">Server information for " + servername + ":\n" +
|
|
|
|
|
"Known domains => " + res_get.domains.join(", ") + "\n" +
|
|
|
|
|
"Ping => " + res_get.ping + "\n" +
|
|
|
|
|
"Users => " + res_get.online + "/" + res_get.max + "\n" +
|
|
|
|
|
"Bandwidth => " + res_get.bandwidth + "\n" +
|
|
|
|
|
"Country => " + res_get.country.name + " (" + res_get.country.code + ")\n" +
|
|
|
|
|
"Version => " + res_get.version + "\n" +
|
|
|
|
|
"Website => " + website
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
}catch(err){
|
|
|
|
|
|
|
|
|
|
send(msg, "lolcat.ca api sucks and is offline and dead");
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "prop":
|
|
|
|
|
try{
|
|
|
|
|
var res = await fetch("https://www.hamqsl.com/solarn0nbh.php");
|
|
|
|
|
var res_get = await res.buffer();
|
|
|
|
|
|
|
|
|
|
send(msg, "Good news: the sun has not yet exploded", res_get);
|
|
|
|
|
}catch(err){
|
|
|
|
|
|
|
|
|
|
send(msg, "Could not fetch image!!! FUCK!!!!111\n" + err);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "img":
|
|
|
|
|
case "im":
|
|
|
|
|
case "i":
|
|
|
|
|
|
|
|
|
|
if(value.trim() == ""){
|
|
|
|
|
|
|
|
|
|
send(msg, "You need to search for something cum licker!!!");
|
|
|
|
|
return;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
global_page = 1;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-08 05:19:01 +00:00
|
|
|
|
try{
|
2024-11-24 10:18:05 +00:00
|
|
|
|
var res = await fetch(instance + "/api/v1/images?s=" + encodeURIComponent(value) + "&nsfw=" + (ddg_mod ? "no" : "yes") + "&scraper=" + scraper);
|
2024-11-08 05:19:01 +00:00
|
|
|
|
var res_get = await res.json();
|
|
|
|
|
|
|
|
|
|
if(res_get.status != "ok"){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-08 05:19:01 +00:00
|
|
|
|
send(msg, "Shit!!!!! 4get sucks balls and returned this error: " + res_get.status);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(res_get.image.length === 0){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
send(msg, "No results found for " + value + "!!");
|
2024-11-08 05:19:01 +00:00
|
|
|
|
break;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
2024-11-08 05:19:01 +00:00
|
|
|
|
}catch(error){
|
|
|
|
|
|
|
|
|
|
send(msg, "4get returned invalid response!!!!!! piece of fuckgin shit!!!11!111");
|
2024-11-24 10:18:05 +00:00
|
|
|
|
break;
|
2024-11-08 05:19:01 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
results_cache = res_get.image;
|
|
|
|
|
is_pp_xeno = false;
|
|
|
|
|
|
|
|
|
|
await serveddg(msg, res_get.image, 1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "scraper":
|
|
|
|
|
switch(value.toLowerCase()){
|
|
|
|
|
|
|
|
|
|
case "ddg":
|
|
|
|
|
case "yandex":
|
|
|
|
|
case "brave":
|
|
|
|
|
case "google":
|
|
|
|
|
case "google_cse":
|
2024-11-08 05:31:53 +00:00
|
|
|
|
case "startpage":
|
|
|
|
|
case "qwant":
|
|
|
|
|
case "yep":
|
|
|
|
|
case "solofield":
|
2024-11-08 05:19:01 +00:00
|
|
|
|
case "imgur":
|
|
|
|
|
case "ftm":
|
|
|
|
|
scraper = value.toLowerCase();
|
|
|
|
|
send(msg, "Scraper set to " + scraper + "!!");
|
|
|
|
|
break;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-11-08 05:19:01 +00:00
|
|
|
|
default:
|
2024-11-24 10:18:05 +00:00
|
|
|
|
send(msg, ">Current scraper: " + scraper +"\nChoices are: ddg, yandex, brave, google, google_cse, startpage, qwant, yep, solofield, imgur, ftm");
|
2024-11-08 05:19:01 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "boobs":
|
|
|
|
|
case "boob":
|
|
|
|
|
case "nsfw":
|
|
|
|
|
switch(value.toLowerCase()){
|
|
|
|
|
|
|
|
|
|
case "yes":
|
|
|
|
|
case "y":
|
|
|
|
|
case "1":
|
|
|
|
|
case "yea":
|
|
|
|
|
case "true":
|
|
|
|
|
case "yup":
|
|
|
|
|
send(msg, "I will now show boobs when using .img");
|
|
|
|
|
ddg_mod = false;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
case "no":
|
|
|
|
|
case "n":
|
|
|
|
|
case "nae":
|
|
|
|
|
case "false":
|
|
|
|
|
case "no":
|
|
|
|
|
case "off":
|
|
|
|
|
case "nope":
|
|
|
|
|
case "nah":
|
|
|
|
|
case "0":
|
|
|
|
|
send(msg, "I will now prevent eagle from jacking off in main chat");
|
|
|
|
|
ddg_mod = true;
|
2023-07-22 19:27:10 +00:00
|
|
|
|
break;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
default:
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
var active = ddg_mod ? "NOT " : "";
|
|
|
|
|
send(msg, "I will " + active + "show boobs. Use .boobs <yes:no> to toggle");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "page":
|
|
|
|
|
case "p":
|
|
|
|
|
value = parseInt(value);
|
|
|
|
|
if(
|
|
|
|
|
isNaN(value) ||
|
|
|
|
|
value == ""
|
|
|
|
|
){
|
|
|
|
|
|
|
|
|
|
send(msg, "You didn't enter a valid number you dumbass!!");
|
2023-07-22 19:27:10 +00:00
|
|
|
|
return;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(results_cache.length === 0){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
|
|
|
|
send(msg, "Search buffer doesn't contain any links you horse fucker!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(
|
2024-08-08 02:40:40 +00:00
|
|
|
|
value > results_cache.length ||
|
2023-07-22 19:39:26 +00:00
|
|
|
|
value <= 0
|
|
|
|
|
){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
send(msg, "Page offset must be between 1 and " + results_cache.length + " you dumbass!!");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
global_page = value;
|
2024-08-08 02:40:40 +00:00
|
|
|
|
|
|
|
|
|
if(is_pp_xeno){
|
|
|
|
|
|
|
|
|
|
await fetch_xeno(results_cache, value, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await serveddg(msg, results_cache, value);
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "pp":
|
|
|
|
|
global_page++;
|
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(global_page > results_cache.length){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
send(msg, "You reached the end of results stupid kike sucker!!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(is_pp_xeno){
|
|
|
|
|
|
|
|
|
|
await fetch_xeno(results_cache, global_page, msg);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
await serveddg(msg, results_cache, global_page);
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case "youtube":
|
|
|
|
|
case "jewtube":
|
|
|
|
|
case "yt":
|
|
|
|
|
if(value.trim() == ""){
|
|
|
|
|
|
|
|
|
|
send(msg, "You need to search for something cum licker!!!");
|
2023-11-24 04:41:04 +00:00
|
|
|
|
break;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
try{
|
2024-11-08 05:19:01 +00:00
|
|
|
|
var res = await fetch(instance + "/api/v1/videos?s=" + encodeURIComponent(value));
|
2024-08-08 02:40:40 +00:00
|
|
|
|
var res_get = await res.json();
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(res_get.status != "ok"){
|
2023-11-24 04:41:04 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
send(msg, "Shit!!!!! 4get sucks balls and returned this error: " + res_get.status);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-11-24 04:41:04 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
if(res_get.video.length === 0){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
send(msg, "No results found for " + value + "!!");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}catch(error){
|
|
|
|
|
|
|
|
|
|
send(msg, "4get returned invalid response!!!!!! piece of fuckgin shit!!!11!111");
|
2023-10-03 03:51:09 +00:00
|
|
|
|
}
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
var text = [];
|
|
|
|
|
|
|
|
|
|
for(var i=0; i<res_get.video.length; i++){
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
if(i === 3){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
break;
|
2023-07-22 19:39:26 +00:00
|
|
|
|
}
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
text.push(
|
|
|
|
|
">Duration: " + (new Date(res_get.video[i].duration * 1000).toISOString().slice(11, 19)) +
|
2024-10-27 18:40:41 +00:00
|
|
|
|
" • Views: " + (new Intl.NumberFormat().format(res_get.video[i].views)) +
|
|
|
|
|
" • Author: " + res_get.video[i].author.name +
|
2023-10-03 03:51:09 +00:00
|
|
|
|
"\n" + res_get.video[i].title +
|
2024-11-03 05:25:35 +00:00
|
|
|
|
"\n▶ " + res_get.video[i].url
|
2023-10-03 03:51:09 +00:00
|
|
|
|
);
|
2023-07-22 19:27:10 +00:00
|
|
|
|
}
|
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
send(msg, "Search results for \"" + value + "\"\n\n" + text.join("\n\n"));
|
2023-07-22 19:39:26 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2023-11-25 00:00:50 +00:00
|
|
|
|
case "x":
|
|
|
|
|
case "xeno":
|
2024-08-08 02:40:40 +00:00
|
|
|
|
case "xeno-canto":
|
2023-11-25 00:00:50 +00:00
|
|
|
|
if(value.trim() == ""){
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"You must give me a search term you autistic cocksucker with no legs!!\nExample: .x owl"
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var res = await fetch("https://xeno-canto.org/api/2/recordings?query=" + encodeURIComponent(value));
|
|
|
|
|
var res_get = await res.json();
|
|
|
|
|
|
|
|
|
|
if(res_get.recordings.length === 0){
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"No recordings found for \"" + value + "\"!!!!!"
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2024-08-08 02:55:36 +00:00
|
|
|
|
global_page = 1;
|
2024-08-08 02:40:40 +00:00
|
|
|
|
is_pp_xeno = true;
|
|
|
|
|
results_cache = res_get.recordings;
|
2023-11-25 00:00:50 +00:00
|
|
|
|
|
2024-08-08 02:40:40 +00:00
|
|
|
|
await fetch_xeno(res_get.recordings, 1, msg);
|
2023-11-25 00:00:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2024-10-06 01:59:50 +00:00
|
|
|
|
case "fortune":
|
|
|
|
|
case "f":
|
2024-10-06 02:12:46 +00:00
|
|
|
|
send(msg, fortunes[Math.floor(Math.random() * fortunes.length)]);
|
2024-10-06 01:59:50 +00:00
|
|
|
|
break;
|
|
|
|
|
|
2024-11-03 22:28:31 +00:00
|
|
|
|
case "list":
|
2024-11-04 14:51:47 +00:00
|
|
|
|
case "l":
|
2024-11-03 22:28:31 +00:00
|
|
|
|
if(mc_bridge_enabled === false){
|
|
|
|
|
|
2024-11-04 14:51:47 +00:00
|
|
|
|
send(msg, "Deekcraft bridge is disabled");
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(mc_logged_in === false){
|
|
|
|
|
|
|
|
|
|
send(msg, "Deekcraft is offline");
|
2024-11-03 22:28:31 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
">Players online on deekcraft:\n" +
|
2024-11-03 22:55:21 +00:00
|
|
|
|
(Object.keys(mc_bot.players).filter(player => mc_bot.players[player].ping !== undefined))
|
2024-11-03 22:28:31 +00:00
|
|
|
|
.join("\n")
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
case "help":
|
|
|
|
|
case "h":
|
|
|
|
|
send(
|
|
|
|
|
msg,
|
|
|
|
|
"== help menu ==\n\n" +
|
|
|
|
|
".help => lol idk\n" +
|
|
|
|
|
".img/.im/.i => search duckduckgo for birds\n" +
|
|
|
|
|
".boobs <yes:no> => Boobs?\n" +
|
|
|
|
|
".page/.p => get page offset for image search\n" +
|
|
|
|
|
".pp => get next page\n" +
|
2024-10-06 02:12:46 +00:00
|
|
|
|
".fortune/.f => fortune teller cause cynic cant code :trol:\n" +
|
|
|
|
|
".yt/.youtube => search the jewish propaganda catalog\n" +
|
2023-11-25 00:00:50 +00:00
|
|
|
|
".x/xeno => search for bird sounds\n" +
|
2023-07-22 19:39:26 +00:00
|
|
|
|
".roll/.r => Because deekchat was too slow\n" +
|
|
|
|
|
".mumble/.m <[optional]ip:port> => check if lolcat died\n" +
|
|
|
|
|
".prop => check if the sun has exploded or smth\n" +
|
2024-11-03 22:28:31 +00:00
|
|
|
|
".list => players online on deekcraft\n" +
|
2023-07-22 19:39:26 +00:00
|
|
|
|
".ping => spam deekchat"
|
|
|
|
|
);
|
|
|
|
|
break;
|
|
|
|
|
}
|
2023-07-22 19:27:10 +00:00
|
|
|
|
});
|
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
deek.on("close", function(channel){
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-10-03 03:51:09 +00:00
|
|
|
|
console.log("It's over. Disconnected from websocket. Attempting reconnection in 10 seconds");
|
2023-07-22 19:39:26 +00:00
|
|
|
|
|
2024-11-03 05:49:02 +00:00
|
|
|
|
fs.utimesSync(__filename, Date.now(), Date.now());
|
2023-07-22 19:39:26 +00:00
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
deek.on("error", function(message){
|
|
|
|
|
|
|
|
|
|
console.error("Serber error: " + message + ". Attempting reconnection in 10 seconds");
|
|
|
|
|
|
2024-11-03 05:49:02 +00:00
|
|
|
|
fs.utimesSync(__filename, Date.now(), Date.now());
|
2023-07-22 19:39:26 +00:00
|
|
|
|
});
|
2023-07-22 19:27:10 +00:00
|
|
|
|
|
2023-07-22 19:39:26 +00:00
|
|
|
|
// connect to serber
|
2023-11-24 04:41:04 +00:00
|
|
|
|
handshake(name, password);
|