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cesContent":["/**\n * Minified by jsDelivr using Terser v5.39.0.\n * Original file: /npm/chat-room-bot@1.0.1/index.js\n *\n * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files\n */\n","const settings = require(\"./data.json\");\r\nconst axios = require('axios');\r\nconst socket = require('socket.io-client')(settings.baseURL);\r\nconst { EventEmitter } = require('events');\r\nconst { send } = require(\"process\");\r\n\r\nfunction requestHome(url,data){ \r\n    return new Promise( (res,rej) => {\r\n                axios\r\n        .post(settings.baseURL+url, data)\r\n        .then((rees) => {\r\n            res(rees.data)\r\n        })\r\n        .catch((error) => {\r\n            res(error.response)\r\n  })\r\n    });\r\n};\r\n\r\nfunction messageBuilder(data){\r\n    const roomID = data.roomID;\r\n    sendMsg = function (message){\r\n        sendToChannel(roomID, message)\r\n    };\r\n    return {\r\n        content:data.content,\r\n        sentAt:data.time,\r\n        room:{\r\n            id:data.roomID,\r\n            send:sendMsg\r\n        },\r\n        author:{\r\n            isBot: data.isBot,\r\n            username:data.author.username,\r\n            id:data.author.id,\r\n            icon:data.author.icon\r\n        }\r\n    };\r\n};\r\n\r\nfunction sendToChannel(roomID, message){\r\n    requestHome(\"/message\",{ roomID, message, WsToken:global.WsToken })\r\n};\r\n\r\nclass Client extends EventEmitter{\r\n\r\n    async login(email,pass){\r\n        socket.on(\"message\",async (data) => {\r\n           const message = await messageBuilder(data)\r\n            this.emit(\"message\",  message)\r\n        });\r\n        return new Promise(async (res, rej) => {\r\n\r\n            const data = await requestHome(`/auth`,{type:\"bot\",username:email, password:pass});\r\n            if (data.error){\r\n                if (data.error == 0) rej(\"Email or Password is incorrect!\")\r\n            }\r\n            socket.emit(\"ws_login\",data.WsToken)\r\n\r\n              this.loggedIn=true;\r\n              global.WsToken = data.WsToken;\r\n            res(data)\r\n        });\r\n        \r\n    };\r\n\r\n    \r\n\r\n    \r\n\r\n\r\n  }\r\n\r\nmodule.exports = {\r\n    Client,\r\n};\r\n"]}