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
14.95k stars 3.55k forks source link

On forward message - return promise with message id #967

Open YehudaEi opened 2 years ago

YehudaEi commented 2 years ago

Is your feature request related to a problem? Please describe. My problem is that when I forward a message using forward function then I don't get back the ID of the message.

Describe the solution you'd like What I would love for is to change the forward function that returns promise with the id of the message (Line 314). https://github.com/pedroslopez/whatsapp-web.js/blob/b60029ed09fc44fdc7531da9fe8dc47823783102/src/structures/Message.js#L307-L314

jonatasleal commented 2 years ago

@YehudaEi hey, were you able to forward a message to a group chat (@g.us)? Could you please share some example code? Thank you!

YehudaEi commented 2 years ago
let success = await msg.forward("972XXXXXXXXX-1584000000@g.us");

For me it works great...

shelomito12 commented 1 year ago
let success = await msg.forward("972XXXXXXXXX-1584000000@g.us");

For me it works great...

I've tried this (forwarding to a group; works) but when people on the group starts chatting, the bot also forwards these messages within the same group. Do you have some code to prevent this?

Thanks!

PurpShell commented 1 year ago
let success = await msg.forward("972XXXXXXXXX-1584000000@g.us");

For me it works great...

I've tried this (forwarding to a group; works) but when people on the group starts chatting, the bot also forwards these messages within the same group. Do you have some code to prevent this?

Thanks!

this is an error with your implementation, or WhatsApp Web. We use the exact functions triggered.

I''ll be working on this

shelomito12 commented 1 year ago

I solved it with this (was only for testing purposes):

let phone = msg.from;
    if (msg.from.includes("@g.us")) {
      console.log("not sending message");
    } else {
      client.sendMessage(
        "130258963147770@g.us",
        "wa.me/" + phone.split("@", 1)[0] + " sent this message:\n\n" + msg.body
      );
    }
gushome7 commented 1 year ago

You can use type==="chat" to prevent group propagation

El 29/12/22 a las 10:50, Zvi escribió:

I solved it with this (was only for testing purposes):

let phone = msg.from; if @.")) { console.log("not sending message"); } else { client.sendMessage( @.", "wa.me/" + phone.split("@", 1)[0] + " sent this message:\n\n" + msg.body ); }

— Reply to this email directly, view it on GitHub https://github.com/pedroslopez/whatsapp-web.js/issues/967#issuecomment-1367335388, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACLIMBR76MSNUD4PC35DJ53WPWJI5ANCNFSM5HXTJJSQ. You are receiving this because you are subscribed to this thread.Message ID: @.***>

-- Gustavo Hernández Baratta camundaNET -http://www.camundanet.com

DesaiVishv commented 8 months ago
130258963147770

what if i want to forword image or somthing like that. do you have any code reference for forword all type of message ?

also what is this "972XXXXXXXXX-1584000000@g.us" can you also explain this arg where i can get this arg. @YehudaEi @gushome7 @jzvi12 @PurpShell