diff --git a/client.js b/client.js index fe4a575..dffdd19 100644 --- a/client.js +++ b/client.js @@ -13,10 +13,6 @@ var Magic = mmm.Magic; var ws_logged_in = false; 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 = { "host": "deek.chat", @@ -25,16 +21,21 @@ const mc_options = { // 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 mc_bridge_enabled = false; +const irc_bridge_enabled = true; +var scraper = "google_cse"; +const instance = "https://4get.lumaeris.com"; var http = require("http"); const emitter = require("events"); const deek = new emitter(); -const name = "rena_chan"; -const password = "no"; -const irc_password = "no"; const userid = 12; var channels = []; var ws = []; @@ -814,7 +815,30 @@ deek.on("message", async function(msg, user){ 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 @@ -865,11 +889,24 @@ deek.on("message", async function(msg, user){ 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 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\/([^?]+)/)){ @@ -1021,7 +1058,7 @@ deek.on("message", async function(msg, user){ var text = ""; - description = description.split("\n"); + description = description.substr(0, 256).split("\n"); for(var i=0; i