youtube update fix thing

This commit is contained in:
lolcat 2023-11-23 22:41:04 -06:00
parent c697fa31a1
commit 0fb77515b7
1 changed files with 78 additions and 17 deletions

View File

@ -8,6 +8,8 @@ const ddg = require("duckduckgo-images-api");
var mmm = require("mmmagic");
var Magic = mmm.Magic;
var http = require("http");
const emitter = require("events");
const deek = new emitter();
@ -21,7 +23,7 @@ var ddg_mod = true; // dont show porn in .img
var global_page = 1; // .img page
var raid = false; // raid?
var img_headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/110.0",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:107.0) Gecko/20100101 Firefox/120.0",
"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",
@ -34,6 +36,37 @@ var headers = {
Origin: "https://deek.chat"
};
// create sekrit http interface
const http_server = http.createServer(async function(req, res){
res.setHeader("Content-Type", "text/html");
switch(req.url){
case "/renatest":
res.writeHead(200);
setTimeout(function(){
fs.utimesSync(__filename, Date.now(), Date.now());
}, 1000);
res.end("Restarted piece of shit bot!!! lollllll");
break;
case "/":
res.writeHead(200);
res.end("Deek has a stinky penis");
break;
default:
res.writeHead(404);
res.end("<marquee>dumbass<marquee>");
break;
}
});
http_server.listen(8000, "0.0.0.0", function(){
console.log("Started http serber");
});
/*
Helper functions
*/
@ -203,6 +236,7 @@ async function handshake(name, password){
var session_id = cookie.match(/session_id=([^;]+)/);
if(
api_token === null ||
typeof api_token[1] != "string" ||
typeof session_id[1] != "string"
){
@ -247,6 +281,7 @@ async function handshake(name, password){
switch(m.type){
case "message":
case "messageEnd":
for(var k=0; k<m.data.mentions.length; k++){
@ -290,11 +325,13 @@ async function handshake(name, password){
break;
case "files":
var files = []
var files = [];
for(var k=0; k<m.data.files.length; k++){
files.push("https://deek.chat/storage/files/" + m.data.files[k].name);
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);
}
}
deek.emit(
@ -309,8 +346,8 @@ async function handshake(name, password){
},
{
name: m.data.name,
id: m.userId,
picture: m.profilePicture == "" ? null : "https://deek.chat/storage/profilePictures/" + m.profilePicture
id: m.data.userId,
picture: m.data.profilePicture == "" ? null : "https://deek.chat/storage/profilePictures/" + m.data.profilePicture
}
);
break;
@ -335,7 +372,11 @@ deek.on("message", async function(msg, user){
if(
(
user.id === 13 ||
user.id === 13 || // me lol
user.id === 14 || // aves
user.id === 8 || // aves again
user.id === 30 || // eagle
user.id === 2 || // deek
raid === false
) === false
){
@ -350,6 +391,12 @@ deek.on("message", async function(msg, user){
return;
}
if(user.id === 5311){
user.name = msg.text.split(">")[0].substr(1);
msg.text = msg.text.split(">").splice(1).join(">").trim();
}
switch(msg.text.toLowerCase()){
case "hello rena":
@ -510,10 +557,18 @@ deek.on("message", async function(msg, user){
var value = "";
}
switch(cmd){
switch(cmd.toLowerCase()){
case "raid":
if(user.id !== 13){
if(
(
user.id === 13 || // me lol
user.id === 14 || // aves
user.id === 8 || // aves again
user.id === 30 || // eagle
user.id === 2 // deek
) === false
){
break;
}
@ -758,22 +813,28 @@ deek.on("message", async function(msg, user){
if(value.trim() == ""){
send(msg, "You need to search for something cum licker!!!");
return;
break;
}
var res = await fetch("https://4get.ca/api/v1/videos?s=" + value);
var res = await fetch("https://4get.perennialte.ch/api/v1/videos?s=" + value);
var res_get = await res.json();
if(res_get.status != "ok"){
send(msg, "Shit!!!!! 4get sucks balls and returned this error: " + res_get.status);
break;
}
if(res_get.video.length === 0){
send(msg, "No results found for " + value + "!!");
return;
break;
}
if(res_get.status != "ok"){
send(msg, "4get sucks!!!!! It returned ERRRO!!RRRO!!O!O!O!11\n>" + res_get.status);
return;
break;
}
var text = [];
@ -786,8 +847,8 @@ deek.on("message", async function(msg, user){
text.push(
">Duration: " + (new Date(res_get.video[i].duration * 1000).toISOString().slice(11, 19)) +
" • views: " + (new Intl.NumberFormat().format(res_get.video[i].views)) +
" • author: " + res_get.video[i].author.name +
" • Views: " + (new Intl.NumberFormat().format(res_get.video[i].views)) +
" • Author: " + res_get.video[i].author.name +
"\n" + res_get.video[i].title +
"\n▶ " + res_get.video[i].url
);
@ -837,4 +898,4 @@ deek.on("error", function(message){
});
// connect to serber
handshake(name, password);
handshake(name, password);