From 98b71ac4661714a0557db6834ae254f3f26f7731 Mon Sep 17 00:00:00 2001 From: lolcat Date: Sun, 24 Nov 2024 05:18:05 -0500 Subject: [PATCH] added irc brigde --- client.js | 117 ++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 109 insertions(+), 8 deletions(-) diff --git a/client.js b/client.js index d842c09..1873a1a 100644 --- a/client.js +++ b/client.js @@ -1,5 +1,6 @@ const fs = require("fs"); const websocket = require("ws"); +var irc = require("irc"); const fetch = require("node-fetch"); const formdata = require("form-data"); const he = require("he"); @@ -10,8 +11,9 @@ var Magic = mmm.Magic; var ws_logged_in = false; const mineflayer = require("mineflayer"); -const mc_bridge_enabled = true; -const instance = "https://4get.tux.pizza"; +const mc_bridge_enabled = false; +const irc_bridge_enabled = true; +const instance = "https://4get.lumaeris.com"; var scraper = "ddg"; const mc_options = { @@ -21,13 +23,16 @@ const mc_options = { // offline mode }; +const irc_ip = "192.168.0.152"; + var http = require("http"); const emitter = require("events"); const deek = new emitter(); const name = "rena_chan"; -const password = "yourmom"; +const password = "no"; +const irc_password = "no"; const userid = 12; var channels = []; var ws = []; @@ -193,7 +198,7 @@ async function serveddg(msg, results, page){ send( msg, - "Page " + (page + 1) + "/" + (results.length) + "\n[" + results[page].source[0].width + "x" + results[page].source[0].height + "] " + results[page].title + "\n" + results[page].source[0].url, + "Page " + (page + 1) + "/" + (results.length) + "\n[" + results[page].source[0].width + "x" + results[page].source[0].height + "] " + results[page].title + "\n" + results[page].url, res_get ); } @@ -528,6 +533,81 @@ function mc_escape(str){ .replace("\n", " "); } +/* + 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); + break; + } + }); + + irc_client.addListener("error", function(message){ + + console.log("IRC error"); + console.log(message); + + irc_logged_in = false; + irc_debounce = false; + irc_client.disconnect(); + + setTimeout(function(){ + + init_irc(); + }, 2000); + }); +} + +init_irc(); + /* User defined FUN-ctions!!! */ @@ -608,8 +688,6 @@ deek.on("message", async function(msg, user){ // split message into newlines // make sure message gets sent in chunks - var chunks = []; - for(var i=0; iCurrent scraper: " + scraper +"\nChoices are: ddg, yandex, brave, google, google_cse, startpage, qwant, yep, solofield, imgur, ftm"); break; } break;