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.08k stars 592 forks source link

TypeError: t.split is not a function #828

Closed YogaSakti closed 3 years ago

YogaSakti commented 3 years ago

Describe the bug i got this error from try catch on my message handler file

Error: Evaluation failed: TypeError: t.split is not a function
    at t.value (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:476525)
    at t.value (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:474682)
    at D:\GitHub\imageToSticker\node_modules\@open-wa\wa-automate\dist\lib\wapi.js:1278:49
    at Array.map (<anonymous>)
    at t.cb (D:\GitHub\imageToSticker\node_modules\@open-wa\wa-automate\dist\lib\wapi.js:1276:19)
    at t.value (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:477069)
    at t.value (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:475399)
    at t.value (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:1180021)
    at t.value [as _triggerEvents] (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:477069)
    at t.value [as trigger] (https://web.whatsapp.com/app.078346a60a3074dee416.js:1:475399)

Steps to Reproduce Steps to reproduce the behavior: i don't now but, when i trace the file from above error D:\GitHub\imageToSticker\node_modules\@open-wa\wa-automate\dist\lib\wapi.js:1278:49 it was came from onGlobalParicipantsChanged function

image

You can see below that for that event I did not enter any further commands

create() code This is the code i use to create the client

const start = (client) => {
    console.log('[DEV]', color('Red Emperor', 'yellow'))
    console.log('[CLIENT] CLIENT Started!')

    // Force it to keep the current session
    client.onStateChanged((state) => {
        console.log('[Client State]', state)
        if (state === 'CONFLICT') client.forceRefocus()
    })

    // listening on message
    client.onMessage((message) => {
        client.getAmountOfLoadedMessages() // Cut message Cache if cache more than 3K
            .then((msg) => {
                if (msg >= 3000) {
                    console.log('[CLIENT]', color(`Loaded Message Reach ${msg}, cuting message cache...`, 'yellow'))
                    client.cutMsgCache()
                }
            })
        // Message Handler
        msgHandler(client, message)
    })

    // listen group invitation
    client.onAddedToGroup(({ groupMetadata: { id }, contact: { name } }) =>
        client.getGroupMembersId(id)
            .then((ids) => {
                console.log('[CLIENT]', color(`Invited to Group. [ ${name} : ${ids.length}]`, 'yellow'))
                // conditions if the group members are less than 10 then the bot will leave the group
                if (ids.length <= 10) {
                    client.sendText(id, 'Sorry, the minimum group member is 10 user to use this bot. Bye~').then(() => client.leaveGroup(id))
                } else {
                    client.sendText(id, `Hello group members *${name}*, thank you for inviting this bot, to see the bot menu send *#menu*`)
                }
            }))

    client.onRemovedFromGroup((data) => {
        // console.log(data)
    })

    // listen paricipant event on group (wellcome message)
    client.onGlobalParicipantsChanged((event) => {
        // if (event.action === 'add') client.sendTextWithMentions(event.chat, `Hello, Welcome to the group @${event.who.replace('@c.us', '')} \n\nHave fun with us✨`)
    })

    client.onIncomingCall((callData) => {
        // client.contactBlock(callData.peerJid)
    })
}

create('Imperial', {
    headless: headless,
    qrRefreshS: 20,
    qrTimeout: 0,
    authTimeout: 0,
    autoRefresh: true,
    restartOnCrash: start,
    cacheEnabled: false,
    // executablePath: execPath,
    useChrome: true,
    killProcessOnBrowserClose: true,
    throwErrorOnTosBlock: false,
    chromiumArgs: [
        '--no-sandbox',
        '--disable-setuid-sandbox',
        '--aggressive-cache-discard',
        '--disable-cache',
        '--disable-application-cache',
        '--disable-offline-load-stale-cache',
        '--disk-cache-size=0'
    ]
})
    .then((client) => start(client))
    .catch((err) => new Error(err))

Expected behavior A clear and concise description of what you expected to happen.

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

Debug Info {
  WA_VERSION: 2.2037.6,
  PAGE_UA: WhatsApp/2.2029.4 Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36,
  WA_AUTOMATE_VERSION: 2.0.23,
  BROWSER_VERSION: HeadlessChrome/87.0.4251.0
}

Screenshots

Host (please complete the following information):

Additional context

smashah commented 3 years ago

@YogaSakti I'm unable to recreate this issue, unfortunately. Is this still happening? Does this still happen with a non-empty callback? Maybe just console log the event?

smashah commented 3 years ago

closing for now. thanks