const { Client, LocalAuth } = require('whatsapp-web.js'); const axios = require('axios'); class WhasAppClient { constructor(be) { this.clientId = be; this.isGenerateQr = false; this.client = new Client({ puppeteer: { args: ['--no-sandbox'], }, authStrategy: new LocalAuth({ clientId: this.clientId }), webVersionCache: { type: "remote", remotePath: "https://raw.githubusercontent.com/wppconnect-team/wa-version/main/html/2.2412.54.html", }, }); this.client.initialize(); this.client.on('authenticated', async () => { console.log(`be:${this.clientId}:Authenticated`); }); let that = this.client; this.client.on('message', async (msg) => { // console.log(`be:${this.clientId}:message:${JSON.stringify(msg)}`); // axios.post('https://nexilis.io/chatgpt/gptnexilis', [{ // role: 'user', // content: msg.body // }], { // headers: { // 'User-Agent': 'easySoftIndonesia', // 'Cookie': 'PHPSESSID=123;MOBILE=123' // } // }) // .then(function (response) { // console.log(`response:${JSON.stringify(response.data)}`); // that.sendMessage(msg.from, response.data.content); // }) // .catch(function (error) { // console.log(error); // }); }); } } module.exports.WhasAppClient = WhasAppClient;