This commit is contained in:
lolcat 2024-11-03 16:59:48 -05:00
parent 243d49a6e4
commit 7f01482a6e
1 changed files with 8 additions and 0 deletions

View File

@ -8,6 +8,8 @@ const ddg = require("duckduckgo-images-api");
var mmm = require("mmmagic"); var mmm = require("mmmagic");
var Magic = mmm.Magic; var Magic = mmm.Magic;
var ws_logged_in = false;
const mineflayer = require("mineflayer"); const mineflayer = require("mineflayer");
const mc_bridge_enabled = true; const mc_bridge_enabled = true;
@ -200,6 +202,8 @@ async function serveddg(msg, results, page){
*/ */
async function send(channel, text, file = null, forcemime = null){ async function send(channel, text, file = null, forcemime = null){
if(ws_logged_in === false){ return; }
if(typeof channel == "object"){ if(typeof channel == "object"){
channel = channel.channel; channel = channel.channel;
@ -252,6 +256,7 @@ async function send(channel, text, file = null, forcemime = null){
/* /*
Handshake Handshake
*/ */
async function handshake(name, password){ async function handshake(name, password){
/* /*
@ -319,6 +324,7 @@ async function handshake(name, password){
ws.once("open", function(){ ws.once("open", function(){
ws_logged_in = true;
deek.emit("login"); deek.emit("login");
const keep_alive = setInterval(function(){ const keep_alive = setInterval(function(){
@ -342,6 +348,7 @@ async function handshake(name, password){
ws.once("close", function(){ ws.once("close", function(){
ws_logged_in = false;
deek.emit("close"); deek.emit("close");
}); });
@ -436,6 +443,7 @@ async function handshake(name, password){
ws.on("error", function(code, reason){ ws.on("error", function(code, reason){
ws_logged_in = false;
deek.emit("error", "code=" + code + " reason=" + reason); deek.emit("error", "code=" + code + " reason=" + reason);
}); });
} }