Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Qr code take long time and sometimes it stack #41

Closed
roysG opened this issue Jul 16, 2022 · 2 comments
Closed

Qr code take long time and sometimes it stack #41

roysG opened this issue Jul 16, 2022 · 2 comments

Comments

@roysG
Copy link

roysG commented Jul 16, 2022

Screen Shot 2022-07-16 at 8 41 58

`const hydraBot = require('hydra-bot');
const mime = require('mime-types');
const fs = require('fs');

(async () => {

let client;
// start bot service
const ev = await hydraBot.initServer({
    puppeteerOptions: {
        headless: process.platform === 'linux' ? true : false ,
        executablePath: process.platform === 'linux' ? "/usr/bin/google-chrome" : "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
        args: ['--no-sandbox'], // Additional arguments to pass to the browser instance. adding any parameter you will replace the default args of the project
    }
});

// return to current whatsapp interface
ev.on('interfaceChange', (change) => {
    console.log("interfaceChange: ", change);
});

// return qrcode parameters
ev.on('qrcode', (qrcode) => {
    console.log('qrcode: ', qrcode);
});

// return connection information
ev.on('connection', async (conn) => {

    // browser information!
    if (conn.statusFind === 'browser') {
        console.log('info Browser: ', conn.text);
    }

    // Was connected to whatsapp chat
    if (conn.connect) {
        client = conn.client;
        // send a text message
        await client.sendMessage({
            to: "0000000000@c.us", // you can pass the contact number or group number
            body: "hi i'm hydra bot", // message text
            options: {
                type: 'text', // shipping type
            }
        }).then((result) => {
            console.log(result); // message result
        }).catch((error) => {
            console.log(error); // message error
        });
    }
});

// return receive new messages
ev.on('newMessage', async (newMsg) => {
    // when is received
    if (!newMsg.result.isSentByMe) {
        // message received!
        console.log('NewMessageReceived: ', newMsg.result);
        // dowload files
        if (newMsg.result.isMedia === true || newMsg.result.isMMS === true) {
            const buffer = await client.decryptFile(newMsg.result);
            // At this point you can do whatever you want with the buffer
            // Most likely you want to write it into a file
            const fileName = `some-file-name.${mime.extension(newMsg.result.mimetype)}`;
            fs.writeFile(fileName, buffer, (err) => {
                console.log(err);
            });
        }
    }
    // when is it sent
    if (!!newMsg.result.isSentByMe) {
        // Message sent
        console.log('NewMessageSent: ', newMsg.result);
    }
});

// returns the status of each message
ev.on('newOnAck', async (event) => {
    console.log('id Message: ', event.id._serialized); // message id
    console.log('Status Message: ', event.ack); // -7 = MD_DOWNGRADE, -6 = INACTIVE, -5 = CONTENT_UNUPLOADABLE, -4 = CONTENT_TOO_BIG, -3 = CONTENT_GONE, -2 = EXPIRED, -1 = FAILED, 0 = CLOCK, 1 = SENT, 2 = RECEIVED, 3 = READ, 4 = PLAYED
    console.log('From Message: ', event.from); // from message
    console.log('To Message: ', event.to); // to message
});

})();`
Screen Shot 2022-07-16 at 8 46 42

@roysG roysG changed the title The window whatsapp stack in specific settings The window whatsapp stack when define the executablePath Jul 16, 2022
@roysG
Copy link
Author

roysG commented Jul 16, 2022

Steps to repreduce:

  1. Paste my code
  2. Run the code
  3. Stop the code
  4. Run again
  5. Stop again
  6. Run again. This time the window will stack in the image i attached

When i removed the generated folder "token", then i saw the qr code again.

but the problem repeat himself when restart the browser.

@roysG roysG changed the title The window whatsapp stack when define the executablePath Qr code take long time and sometimes it stack Jul 16, 2022
@roysG
Copy link
Author

roysG commented Jul 16, 2022

any update?

It also important to mention that this bug repreduce when session is exists

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants