Auties00 / Cobalt

Standalone unofficial fully-featured Whatsapp Web and Mobile API for Java and Kotlin
MIT License
616 stars 180 forks source link

How to forward messages? #417

Closed incapdns closed 6 months ago

incapdns commented 8 months ago

How to forward messages ?

Example, send forwarded messages to 5 numbers

incapdns commented 8 months ago

Update: The recipient is receiving the message normally, the problem is that the sender (me) is not showing the history of sent messages, it is as if I had not sent any message.

val whatsapp = Whatsapp
        .webBuilder()
        .newConnection(UUID.fromString("e58ed763-928c-4155-bee9-fdbaaadc15f3"))
        .historyLength(WebHistoryLength.ZERO)
        .registered()
        .get()
        .connect()
        .join()

    val message = TextMessage.builder() // Create a new text message
        .text("Testing abc 123 !") // Set the text of the message
        .build();

    val chat = ContactJid.of("+553199140485")

    val key = MessageKey.builder()
        .chatJid(chat.toJid())
        .fromMe(true)
        .senderJid(whatsapp.store().jid())
        .build()

    val info = MessageInfo.builder()
        .senderJid(whatsapp.store().jid())
        .key(key)
        .message(MessageContainer.of(message))
        .timestampSeconds(Clock.nowSeconds())
        .broadcast(chat.toJid().hasServer(ContactJid.Server.BROADCAST))
        .build()

    val list = mutableListOf(ContactJid.of("+553199140485"), ContactJid.of("+553199140485"))

    var request = MessageSendRequest
        .builder()
        .info(info)
        .recipients(list)
        .build()

    whatsapp
        .sendMessage(request)
        .join()
incapdns commented 8 months ago

Another thing I noticed is that two different contacts cannot receive the message, only the chatid contact