pedroslopez / whatsapp-web.js

A WhatsApp client library for NodeJS that connects through the WhatsApp Web browser app
https://wwebjs.dev
Apache License 2.0
15.37k stars 3.67k forks source link

Auto Create Status After other people create status #453

Closed welldy33 closed 3 years ago

welldy33 commented 3 years ago

Bug description

Some times Reply Message being status automaticly

Reproduction steps

Steps to reproduce the behavior:

  1. Reply Message
  2. Message Reply well
  3. After few minutes Reply Message Will Be show on Status
    ...

Expected behavior

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

Relevant code

If applicable, add code snippets to help explain your problem.

Environment (please complete the following information):

WhatsApp -Standard

Library

Additional context

its happen some times, not every reply message be status

parthibd commented 3 years ago

Can you please explain in detail what problem you are exactly facing . I am unable to understand.

welldy33 commented 3 years ago

now the issue fix with his self.

welldy33 commented 3 years ago

Hi All, Now the issue its happen, after I analyze , its Happen after other peopple in my contact create there own status , so directly my whatapps will create status automaticly image

image

THis My Code const axios = require('axios'); const mqtt = require('mqtt') const mqttClient = mqtt.connect('mqtt://192.168.0.133') const fs = require('fs'); const { Client,MessageMedia , Location } = require('whatsapp-web.js'); const forbidWordstr=['Anjing' ,'Babi' ,'Monyet' ,'Kunyuk' ,'bajingan' ,'Asu' ,'Bangsat' ,'Kontol' ,'Memek' ,'Ngentot' ,'Ngewe' ,'Perek' ,'Pecun' ,'Bencong' ,'Banci' ,'Jablay' ,'Bego' ,'Goblok' ,'Idiot' ,'Geblek' ,'Gila' ,'Sinting' ,'Sarap' ,'Stres' ,'Buta' ,'Budek' ,'Jelek' ,'Bolot' ,'Setan' ,'Ngehe' ,'Bejad' ,'Gembel' ,'Tai' ,'Brengsek' ,'Anjay' ,'Fuck' ,'FUCK YOU' ,'fuck u' ,'bitch' ,'Itil' ,'toket' ] const ForbidWord=function(myWord){ var obj={} var ret=false; for(var i=0;i<forbidWordstr.length;i++){ var iscontain=myWord.toUpperCase().includes(forbidWordstr[i].toUpperCase()); if(iscontain){ ret=true; break; } } return ret; } const SESSION_FILE_PATH = './session.json'; let sessionCfg; if (fs.existsSync(SESSION_FILE_PATH)) { sessionCfg = require(SESSION_FILE_PATH); }

const waClient = new Client({ puppeteer: { executablePath: 'C:/Program Files/Google/Chrome/Application/chrome.exe', headless: false }, session: sessionCfg }); waClient.initialize();

//MQTT START=================================

//MQTT END ==================================

//WAClient START================================= waClient.on('qr', (qr) => { console.log("LOG: " + qr); });

waClient.on('ready', () => { console.log('LOG: WA-Client Is Ready'); });

waClient.on('authenticated', (session) => { console.log("LOG: " + 'AUTHENTICATED', session); sessionCfg = session; fs.writeFile(SESSION_FILE_PATH, JSON.stringify(session), function (err) { if (err) { console.error(err); } }); });

waClient.on('auth_failure', msg => { // Fired if session restore was unsuccessfull console.error("LOG: " + 'AUTHENTICATION FAILURE', msg); });

waClient.on('message' /'message'/, async msg => { //reply only from client console.log(msg.body.toString());

var body=msg.body;
if(ForbidWord(body)){
    msg.reply("Hi, jangan gunakan kata kasar yah, yuk coba lagi balas dengan baik");
}else{
    if(body=="1"){
        msg.reply("Lagi Gawe Broo");
    }else if(body=="2"){
        msg.reply("Kepo Anjir");
    }else if(body=="3"){
        msg.reply("Sulit Bro Muka Lu Ga Ketolong");
    }else if(body=="4"){
        msg.reply("Kapan?");
    }else if(body=="5"){
        const media = MessageMedia.fromFilePath('./cdn/wr.jpg');
        msg.reply(media);
        msg.reply(`
        Gimana Ganteng?
        `);
    }else
    {
        msg.reply(`
            Hallo! Welldy Sedang sibuk sekarang , Pesan ini akan di jawab oleh BOT, ada yang bisa aku bantu?
            1. Lagi dimana?
            2. Lagi Apa?
            3. Cariin Pacar Dong Wel.
            4. Maen Yuk?
            5. Minta Foto Lu dong
            <button type="button">Test</button>
        `);
    }
}

});

pedroslopez commented 3 years ago

This happens because you're replying to status messages, which are getting sent to the message event. In the future we'll probably filter out these types of messages automatically, but you can ignore them by adding an early return in your event handler with if(msg.isStatus) return;

welldy33 commented 3 years ago

This happens because you're replying to status messages, which are getting sent to the message event. In the future we'll probably filter out these types of messages automatically, but you can ignore them by adding an early return in your event handler with if(msg.isStatus) return;

Hi @pedroslopez , Thanks For Solution