various embed fix

This commit is contained in:
lolcat 2025-01-11 16:23:35 -05:00
parent a8e7e710d3
commit 93f685e58b
1 changed files with 48 additions and 11 deletions

View File

@ -13,10 +13,6 @@ var Magic = mmm.Magic;
var ws_logged_in = false; var ws_logged_in = false;
const mineflayer = require("mineflayer"); const mineflayer = require("mineflayer");
const mc_bridge_enabled = false;
const irc_bridge_enabled = true;
const instance = "https://4get.lumaeris.com";
var scraper = "google_cse";
const mc_options = { const mc_options = {
"host": "deek.chat", "host": "deek.chat",
@ -25,16 +21,21 @@ const mc_options = {
// offline mode // offline mode
}; };
const name = "rena_chan";
const password = "no";
const irc_password = "no";
const yt_token = "no"
const irc_ip = "192.168.0.152"; const irc_ip = "192.168.0.152";
const mc_bridge_enabled = false;
const irc_bridge_enabled = true;
var scraper = "google_cse";
const instance = "https://4get.lumaeris.com";
var http = require("http"); var http = require("http");
const emitter = require("events"); const emitter = require("events");
const deek = new emitter(); const deek = new emitter();
const name = "rena_chan";
const password = "no";
const irc_password = "no";
const userid = 12; const userid = 12;
var channels = []; var channels = [];
var ws = []; var ws = [];
@ -814,7 +815,30 @@ deek.on("message", async function(msg, user){
try{ try{
if(reddit = link.match(/^https?:\/\/(?:old\.|www\.|m\.)?reddit\.com(\/r\/[^\/]+.*)/i)){ if(chan4 = link.match(/https?:\/\/boards\.4chan\.org\/([A-z0-9]+\/thread\/[0-9]+)/i)){
//
// 4cunt embed
//
chan4 = chan4[1];
// https://boards.4chan.org/g/thread/103852444#replyID
// https://a.4cdn.org/po/thread/570368.json
var res = await fetch("https://a.4cdn.org/" + chan4 + ".json");
var json = await res.json();
if(typeof json.posts[0].sub == "undefined"){
var title = "404 thread ded";
var description = "stupid fucking thread fuck this stupid site";
}else{
var title = json.posts[0].sub;
var description = removehtml(json.posts[0].com);
}
}else if(reddit = link.match(/^https?:\/\/(?:old\.|www\.|m\.)?reddit\.com(\/r\/[^\/]+.*)/i)){
// //
// reddit embed // reddit embed
@ -865,11 +889,24 @@ deek.on("message", async function(msg, user){
watch = watch[2]; watch = watch[2];
} }
var res = await fetch("https://youtube.com/oembed?url=/watch?v=" + watch); var res =
await fetch(
"https://www.googleapis.com/youtube/v3/videos?id=" + watch + "&key=" + yt_token + "&part=snippet,contentDetails,statistics,status"
);
var json = await res.json();
var title = json.items[0].snippet.title;
var description =
"👁️ " + json.items[0].statistics.viewCount + " • 💬 " + json.items[0].statistics.commentCount + " • 📅 " + json.items[0].snippet.publishedAt + "\n" +
json.items[0].snippet.description;
// old shitcode that keeps erroring out
/*var res = await fetch("https://youtube.com/oembed?url=/watch?v=" + watch);
var json = await res.json(); var json = await res.json();
var title = json.title; var title = json.title;
var description = "By " + json.author_name; var description = "By " + json.author_name;*/
}else if(bsky = link.match(/^https?:\/\/bsky\.app\/profile\/([^\/]+)\/post\/([^?]+)/)){ }else if(bsky = link.match(/^https?:\/\/bsky\.app\/profile\/([^\/]+)\/post\/([^?]+)/)){
@ -1021,7 +1058,7 @@ deek.on("message", async function(msg, user){
var text = ""; var text = "";
description = description.split("\n"); description = description.substr(0, 256).split("\n");
for(var i=0; i<description.length; i++){ for(var i=0; i<description.length; i++){