orkestral / venom

Venom is a high-performance system developed with JavaScript to create a bot for WhatsApp, support for creating any interaction, such as customer service, media sending, sentence recognition based on artificial intelligence and all types of design architecture for WhatsApp.
https://orkestral.io
Apache License 2.0
6.03k stars 1.18k forks source link

Is onAnyMessage working now? #2256

Closed ZerXus closed 1 year ago

ZerXus commented 1 year ago

Cant find any listener that work well to recieve incoming and outcoming messages

github-actions[bot] commented 1 year ago

Thank you for joining our community, happy. We are currently fixing this bug, our new version will be released soon.

Working with Love!

jonalan7 commented 1 year ago

you must use the onAnyMessage is working normally! If it takes too long, it may be that you are running on a machine that is already using all the resources!

    client.onAnyMessage((msg) => {
      console.log('Msg: ', msg);
    });
ZerXus commented 1 year ago

Its dont working on my wa image image

jonalan7 commented 1 year ago

put your code here for us to see?

ZerXus commented 1 year ago

import { create, Whatsapp as WhatsappVenom } from 'venom-bot'; import fs from "fs";

import paths from "../utilities/paths.js"; import Database from "../database/database.js"; import whatsappMessage from "../whatsappMessage/whatsappMessage.js";

export default class Whatsapp { constructor(manager) { this.manager = manager; this.options = { session: this.manager, headless: false, // mkdirFolderToken: './data', disableWelcome: true, updatesLog: false, devtools: false, // Open devtools by default debug: false, // Opens a debug session, }; this.db = Database; }

startClient() {
    create(this.options)
        .then(client => {
            this.tryCatchSIGINT(client, () => this.onMessageEvent(client));
        })
        .catch(error => {
            if (!error) return;
            console.log(error);
        });
}

tryCatchSIGINT(client, callback) {
    process.on('SIGINT', () => {
        console.log("Stopping WA-Bot");
        client.close();
    });
    try {
        this.client = client;
        callback();
    } catch (error) {
        console.log(error);
        this.client.close();
    }
}

onMessageEvent() {
    this.client.onAnyMessage(incomingMessage => {
        console.log(incomingMessage);
        // if (incomingMessage.chatId === 'status@broadcast') return;
        //
        // new whatsappMessage(incomingMessage, { client: this.client, manager: this.manager }).parse()
        //     .then(message => {
        //         this.db.storeMessage(message);
        //     });
    })
    // this.client.onMessageEvent(msg => console.log(msg));
}

}

jonalan7 commented 1 year ago

try to run like this!

import { create } from 'venom-bot';

(async () => { create({ session: 'session-name', //name of session headless: false }) .then((client) => start(client)) .catch((erro) => { console.log(erro); });

function start(client) { client.onAnyMessage((msg) => { console.log('Msg: ', msg); }); }

})();

jonalan7 commented 1 year ago

solved?

ZerXus commented 1 year ago

Haven't checked yet, I'll answer when I check

пт, 5 мая 2023 г., 19:35 Jónalan de Lima @.***>:

solved?

— Reply to this email directly, view it on GitHub https://github.com/orkestral/venom/issues/2256#issuecomment-1536357040, or unsubscribe https://github.com/notifications/unsubscribe-auth/AL7PMFQFDZKXBYQISR6VA3TXEUF45ANCNFSM6AAAAAAXURL2A4 . You are receiving this because you authored the thread.Message ID: @.***>

ZerXus commented 1 year ago

Hello! This one dont work too image

ZerXus commented 1 year ago

and sessions dont save, i cant ctrl+c and then re-login again without qr-code

keinou commented 1 year ago

solved?