yayan 1 năm trước cách đây
mục cha
commit
c32c223fd3
2 tập tin đã thay đổi với 16 bổ sung15 xóa
  1. 16 10
      main.js
  2. 0 5
      whatsapp-client.js

+ 16 - 10
main.js

@@ -12,14 +12,16 @@ function createWa(be, res) {
     const wa = new WhasAppClient(be);
     wa.client.on('qr', async qr => {
         console.log(`be:${wa.clientId}:qr:${qr}`);
-        if (res == null) {
-            try {
-                await wa.client.destroy();
-            } catch (error) {
-                console.log(error);
-            }
-            return;
-        }
+        // if (res == null) {
+        //     try {
+        //         await wa.client.destroy();
+        //         fs.rm(`.wwebjs_auth/session-${wa.clientId}`, { recursive: true, force: true }, (error) => {
+        //         });
+        //     } catch (error) {
+        //         console.log(error);
+        //     }
+        //     return;
+        // }
         if (!wa.isGenerateQr) {
             if (res != null) res.json({ status: '00', be: wa.clientId, qr: qr });
         }
@@ -101,11 +103,15 @@ app.post("/api/send/:be", async (req, res) => {
             const data = req.body.message.data;
             const caption = req.body.message.caption;
             let messageMedia = new MessageMedia(media, data, fileName);
-            await client.sendMessage(`${to}@c.us`, messageMedia, { caption: caption });
+            to.forEach( it => {
+                client.sendMessage(`${it}@c.us`, messageMedia, { caption: caption });
+            });
             res.json({ status: '00', be: be });
             return;
         }
-        await client.sendMessage(`${to}@c.us`, message);
+        to.forEach( it => {
+            client.sendMessage(`${it}@c.us`, messageMedia, { caption: caption });
+        });
         res.json({ status: '00', be: be });
     } catch (error) {
         console.log(`error:${error}`);

+ 0 - 5
whatsapp-client.js

@@ -12,11 +12,6 @@ class WhasAppClient {
             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().catch(_ => _);