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

the bot doesn't respond to incoming messages, it even doesn't trigger new messages if needed #2827

Open
conway2024 opened this issue Dec 7, 2024 · 1 comment
Labels
bug Something isn't working needs triage Needs avaliation

Comments

@conway2024
Copy link

Below is my code, I am able to login successfully but after that bot doesn't revert or send message

/* eslint-env node */

// Ignore prettier formatting
// prettier-ignore
const venom = require('venom-bot');

venom
.create(
'zzz', // Session name
(base64Qr, asciiQR) => {
console.log('QR Code:', asciiQR);
},
(statusSession, session) => {
console.log('Status Session:', statusSession);
console.log('Session name:', session);
},
{
headless: false,
devtools: true,
executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe',
logQR: true,
disableSpins: true
}
)
.then((client) => start(client))
.catch((error) => console.error('Error starting Venom:', error));

function start(client) {
// prettier-ignore
console.log("Bot started and listening for messages...");

client.onMessage((message) => {
console.log('Received message:', message.body);
console.log('From:', message.from);
console.log('Is group message:', message.isGroupMsg);

// Log additional message properties
console.log('Message ID:', message.id);
console.log('Timestamp:', message.t);

if (message.body === 'Hi' && message.isGroupMsg === false) {
  console.log('Sending response to:', message.from);
  // prettier-ignore
  client
    .sendText(message.from, 'Hello! This is an automated response from Venom.') 
    .then((result) => {
      console.log('Message sent successfully:', result);
    })
    .catch((error) => {
      console.error('Error sending message:', error);
    });
} else {
  console.log('No match for "Hi".');
}

});
}

@conway2024 conway2024 added bug Something isn't working needs triage Needs avaliation labels Dec 7, 2024
@allanalcantara
Copy link

allanalcantara commented Dec 12, 2024

Below is my code, I am able to login successfully but after that bot doesn't revert or send message

/* eslint-env node */

// Ignore prettier formatting // prettier-ignore const venom = require('venom-bot');

venom .create( 'zzz', // Session name (base64Qr, asciiQR) => { console.log('QR Code:', asciiQR); }, (statusSession, session) => { console.log('Status Session:', statusSession); console.log('Session name:', session); }, { headless: false, devtools: true, executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe', logQR: true, disableSpins: true } ) .then((client) => start(client)) .catch((error) => console.error('Error starting Venom:', error));

function start(client) { // prettier-ignore console.log("Bot started and listening for messages...");

client.onMessage((message) => { console.log('Received message:', message.body); console.log('From:', message.from); console.log('Is group message:', message.isGroupMsg);

// Log additional message properties
console.log('Message ID:', message.id);
console.log('Timestamp:', message.t);

if (message.body === 'Hi' && message.isGroupMsg === false) {
  console.log('Sending response to:', message.from);
  // prettier-ignore
  client
    .sendText(message.from, 'Hello! This is an automated response from Venom.') 
    .then((result) => {
      console.log('Message sent successfully:', result);
    })
    .catch((error) => {
      console.error('Error sending message:', error);
    });
} else {
  console.log('No match for "Hi".');
}

}); }

Try this.

>    const venom = require('venom-bot');
>       venom
>            .create(
>         'zzz', // Session name
>         (base64Qr, asciiQR) => {
>             console.log('QR Code:', asciiQR);
>         },
>         (statusSession, session) => {
>             console.log('Status Session:', statusSession);
>             console.log('Session name:', session);
>         },
>         {
>             headless: 'new',
>             devtools: true,
>             logQR: true,
>             disableSpins: true
>           }
>       )
>      .then((client) => start(client))
>        .catch((error) => console.error('Error starting Venom:', error));
> 
> 
>      function start(client) {
>       console.log("Bot started and listening for messages...");
> 
>     client.onMessage((message) => {
>         console.log('Received message:', message.body);
>         console.log('From:', message.from);
>         console.log('Is group message:', message.isGroupMsg);
>         console.log('Message ID:', message.id);
>         console.log('Timestamp:', message.t);
> 
>         if (message.body === 'Hi' && message.isGroupMsg === false) {
>             console.log('Sending response to:', message.from);
>             client
>                 .sendText(message.from, 'Hello! This is an automated response from Venom.')
>                 .then((result) => {
>                     console.log('Message sent successfully:', result);
>                 })
>                 .catch((error) => {
>                     console.error('Error sending message:', error);
>                 });
>         } else {
>             console.log('No match for "Hi".');
>         }
>     });
> }

Imagem do WhatsApp de 2024-12-12 à(s) 13 59 55_e866c38c
Captura de tela 2024-12-12 144226

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage Needs avaliation
Projects
None yet
Development

No branches or pull requests

2 participants