open-wa / wa-automate-nodejs

๐Ÿ’ฌ ๐Ÿค– The most reliable tool for chatbots with advanced features. Be sure to ๐ŸŒŸ this repository for updates!
https://docs.openwa.dev/
Other
3.05k stars 588 forks source link

Waiting for ripe session bug #3178

Closed joelvitorniino closed 2 months ago

joelvitorniino commented 3 months ago

Are you using the latest version of the library?

What type of session are you experiencing this issue on?

Multi-device and I have set multiDevice to true in my config OR am using the --multi-device flag

What type of host account are you experiencing this issue on?

Personal account (normal)

Mode

EASY API/CLI

Current Behavior

Waiting for ripe session bug

Expected Behavior

Waiting for ripe session bug

Steps To Reproduce

yarn tsx src/app.ts

image

create() code OR full CLI command + CONFIG

import { config } from "dotenv";
import { ChatId, create, Client, Message } from "@open-wa/wa-automate";
import PQueue from "p-queue";
import { CommandExecuter } from "./class/CommandExecuter";

config();

const pqueue = new PQueue({
  concurrency: 1,
  intervalCap: 1,
  carryoverConcurrencyCount: true,
});

let warningMessageSent = false; 

export const initializeApp = async (): Promise<void> => {
  const commandExecuter = new CommandExecuter(__dirname + "/modules/commands");

  const handleMessage = async (client: Client, message: Message) => {
    try {
      const commandRegex = /^!([\w-]+)(?:\s+(.*))?$/;
      const matches = message.body?.match(commandRegex);
      const from = message.from;

      const commandName = matches![1].toLowerCase();

      if (!warningMessageSent) {
        await client.sendText(from, 'Caso o comando demore a ser enviado, รฉ por que estamos operando em filas paralelas!');
        warningMessageSent = true;
      }

      await pqueue.add(async () => {
        await commandExecuter.enqueueCommand(
          client,
          commandName,
          from,
          matches!
        );
      });

      await client.clearAllChats();

      const chat = await client.getAllChatIds()

      chat.forEach(async ch => {
        const result = await client.archiveChat(ch, true);
      });
    } catch {
      return null;
    }
  };

  const startClient = async () => {
    const client = await create({
      authTimeout: 20000,
      bypassCSP: true,
      cachedPatch: true,
      cacheEnabled: false,
      chromiumArgs: [
        "--no-sandbox",
        "--disable-setuid-sandbox",
        "--disable-dev-shm-usage",
        "--disable-accelerated-2d-canvas",
        "--no-first-run",
        "--no-zygote",
        "--single-process",
        "--disable-gpu",
        "--ignore-certificate-errors",
      ],
      corsFix: true,
      sessionId: "niino",
      useChrome: true,
      headless: true,
    });

    client.onMessage(async (message) => {
      await handleMessage(client, message);
    });
  };

  startClient();
};

initializeApp();

DEBUG INFO

WA_VERSION      โ”‚                                                            '2.3000.1012412840'                                                             โ”‚
โ”‚       PAGE_UA       โ”‚ 'WhatsApp/2.2147.16 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36' โ”‚
โ”‚ WA_AUTOMATE_VERSION โ”‚                                                                  '4.68.0'                                                                  โ”‚
โ”‚   BROWSER_VERSION   โ”‚                                                       'HeadlessChrome/123.0.6312.86'                                                       โ”‚
โ”‚         OS          โ”‚                                                                'Linux 6.8'                                                                 โ”‚
โ”‚      START_TS       โ”‚                                                               1711745568601                                                                โ”‚
โ”‚      RAM_INFO       โ”‚                                                     'Total: 16.71 GB | Free: 11.39 GB'                                                     โ”‚
โ”‚    PPTR_VERSION     โ”‚                                                                 '19.11.1'                                                                  โ”‚

Environment

- OS: Linux 6.8
- Node: 20.10.0
- npm: 10.2.5

Screenshots/Logs

-x-

Anything else?

-x-

TVARecordings commented 3 months ago

Hello @joelvitorniino,

I'm not a developer of WA-Automate-Nodejs, but i'm in the dedicated Discord-server. Last month @smashah announced they're expecting that Whatsapp-web's (the site) framework will be updated.

@smashah Has not publicly announced this yet, but the bug you're experiencing, do experience other users too. This is possibly caused by Whatsapp updating their framework.

For now, a temporary fix i have found is doing this:

Close the application (npm, mp2, whatever you use), delete the IGNORE folder & delete the .data.json file. Relaunch the application and connect the host via QR again. Yes, you need to do this every time.

joelvitorniino commented 3 months ago

Okay. Thanks!

2024ๅนด4ๆœˆ1ๆ—ฅ(ๆœˆ) 13:21 TVARecordings @.***>:

Hello @joelvitorniino https://github.com/joelvitorniino,

I'm not a developer of WA-Automate-Nodejs, but i'm in the dedicated Discord-server. Last month @smashah https://github.com/smashah announced they're expecting that Whatsapp-web's (the site) framework will be updated.

@smashah https://github.com/smashah Has not publicly announced this yet, but the bug you're experiencing, do experience other users too. This is possibly caused by Whatsapp updating their framework.

For now, a temporary fix i have found is doing this:

Close the application (npm, mp2, whatever you use), delete the IGNORE folder & delete the .data.json file. Relaunch the application and connect the host via QR again. Yes, you need to do this every time.

โ€” Reply to this email directly, view it on GitHub https://github.com/open-wa/wa-automate-nodejs/issues/3178#issuecomment-2030087019, or unsubscribe https://github.com/notifications/unsubscribe-auth/ARN7CEKSUNCHU4JJIDLDSL3Y3GCQJAVCNFSM6AAAAABFO5ITZGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAMZQGA4DOMBRHE . You are receiving this because you were mentioned.Message ID: @.***>

smashah commented 2 months ago

Rolling into #3184