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.15k stars 600 forks source link

Generic error when including a zero before the number #1498

Closed ahmed-safari closed 3 years ago

ahmed-safari commented 3 years ago

Describe the bug I get a "generic?" error when someone adds a zero before their numbers and after the country code. For example Success if number is +97455xxxxxx Fail with the above error if number is +974055xxxxxx ( same number but with an added zero after the country code )

Steps to Reproduce Steps to reproduce the behavior:

  1. Add zero after country code
  2. Send text message

create() code This is the code you use to create the client. e.g

wa.create({
            sessionId: "InstagramBot",
            skipUpdateCheck: true,
            authTimeout: 0,
            blockCrashLogs: true,
            disableSpins: true,
            headless: true,
            hostNotificationLang: 'en-gb',
            logConsole: false,
            popup: true,
            qrTimeout: 0,
            useChrome: true,
            callTimeout: 90 * 1000,
        })

Expected behavior To either remove the zero and work correctly or to throw a specific error.

DEBUG INFO This is the info printed to the console when you start your app. It should look like this


  | - Browser Launched
  | ┌─────────────────────┬──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
  | │       (index)       │                                                                    Values                                                                    │
  | ├─────────────────────┼──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┤
  | │     WA_VERSION      │                                                                  '2.2108.8'                                                                  │
  | │       PAGE_UA       │ 'WhatsApp/2.2037.6 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.83 Safari/537.36' │
  | │ WA_AUTOMATE_VERSION │                                                                   '3.9.6'                                                                    │
  | │   BROWSER_VERSION   │                                                        'HeadlessChrome/86.0.4240.198'                                                        │
  | │         OS          │                                                                 'Linux 5.4'                                                                  │
  | │      START_TS       │                                                                1616124986913                                                                 │
  | └─────────────────────┴──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┘
  | - Injecting api
  | - WAPI injected
  | - Authenticating
  | - Authenticated
  | - Reinjecting api
  | - WAPI Reinjected
  | - Checking if session is valid
  | - Client is ready
  | - Downloading patches
  | - Installing patches
  | - Patches Installed: 36a8d
  | - Client loaded in 16.906s
  | - Checking License
  | - License Valid: Restricted License Key
  | - 🚀 @OPEN-WA ready for account: 3830

Screenshots If applicable, add screenshots to help explain your problem. Use headless: false to get screenshots

Host (please complete the following information):

Additional context Add any other context about the problem here.

ahmed-safari commented 3 years ago

Quick update: I found a workaround for this issue. I run the phone number through the checkNumberStatus() method and then I get the phone number from the response of that method. I then use the new number ( without the zero ) and send the text message.

smashah commented 3 years ago

@Sp0derDev 974055xxxxxx isn't really a valid number but the library should respond with Error: Number not linked to WhatsApp Account

ahmed-safari commented 3 years ago
Error when sending:  Error: Evaluation failed: TypeError: Cannot read property 'sendMessage' of undefined
    at eval (eval at <anonymous> (:1:27), <anonymous>:1:34774)
    at X (https://web.whatsapp.com/bootstrap_qr.8c6bd07fd55e4b8fbdb7.js:1:307039)

     at MutationObserver.H (https://web.whatsapp.com/bootstrap_qr.8c6bd07fd55e4b8fbdb7.js:1:306620)
     at ExecutionContext._evaluateInternal (/home/nodejs/nodeApps/API/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:217:19)
     at processTicksAndRejections (internal/process/task_queues.js:93:5)
  at async ExecutionContext.evaluate (/home/nodejs/nodeApps/API/node_modules/puppeteer/lib/cjs/puppeteer/common/ExecutionContext.js:106:16)

This is the error I get. Also, as I mentioned above. When I use the checkNumberStatus() it works and returns the number without the extra zero,

smashah commented 3 years ago

thanks for the error logs. seems to be related to #1495

ahmed-safari commented 3 years ago

If you could maybe implement the workaround I mentioned instead of throwing an error. That would be great!

smashah commented 3 years ago

@Sp0derDev please update to v3.9.7 and try again. If it continues then continue the discussion in #1495 as it seems like this is a duplicate issue.