Rhymen / go-whatsapp

WhatsApp Web API
MIT License
2.05k stars 490 forks source link

Just info ... new type of messsage "View Once" , "Buttons" and "List" #588

Closed hrizal closed 2 years ago

hrizal commented 3 years ago

I received a message like this, but it's not handled by this library yet

Type : View Once

        "key": {
                "remoteJid": "XXXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "A470D6994B1530XXXXXXXXXXXXX"
        },
        "message": {
                "viewOnceMessage":  {
                        "message": {
                                "imageMessage": {
                                        "url": "https://mmg.whatsapp.net/d/f/Ah5DkItASZpe5kUS3wFl5TB-eCvybMyNUXXXXXXXX.enc",
                                        "mimetype": "image/jpeg",
                                        "fileSha256": "Py5CDbVCO0NiKEgpQ1qwc2R5wrCdoXXXXXXXXX=",
                                        "fileLength": 106806,
                                        "height": 1600,
                                        "width": 900,
                                        "mediaKey": "IS3KOQrMdfHGO60bFOOSIDvRUIkxfXXXXXXXI=",
                                        "fileEncSha256": "6amXOE72esSpdQ8h+Hj/TtC8Y6OnOr4uQXXXXXX=",
                                        "directPath": "/v/t62.7118-24/35319310_307390284455166_584405XXXXXXXXX.enc?ccb=11-4\u0026oh=887417f31d720b7326143fXXXXXXX\u0026oe=60E5BXXXX",
                                        "mediaKeyTimestamp": 1625237853,
                                        "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABsbGxscGx4hIR4qLSgtKj04MzM4PV1CR0JHQl2NWGdYWGdYjX2Xe3N7l33gsJycsOD/2c7Z//////////////8BGxsbGxwbHiEhHiotKC0qPTgzMzg9XUJHQkdCXY1YZ1hYZ1iNfZd7c3uXfeCwnJyw4P/Zztn////////////////CABEIAD4AIwMBIgACEQEDEQH/xAAvAAACAwEBAAAAAAAAAAAAAAADBAACBQEGAQADAQAAAAAAAAAAAAAAAAABAgMA/9oADAMBAAIQAxAAAACiT6Lgih1RtOPxhcNKZw0011IpaUmudrODPg67OiUFLQ06dOlPObWc8DmzTm3/xAAlEAACAgIBAwMFAAAAAAAAAAABAgADERIEFDFBEyFRIjIzYXH/2gAIAQEAAT8A0qI+wRq0dtUTH7no1IMEZaOoFmJ0NRA7ypS2T4EK22MzKIlhB0eWE7nJlHvSn8gCiooO2JToq4M5lRdxosTiLcjhva1ZxuZTTUEfOwlFuwhodrgVOFhcIMTL77p37GHihyWNYyYN6WwZ1GCDmArYdg05AddSoIUH3MHL1GGQ5j1bkk/EvpAnDvqVNPMbFqEGdQtf0P3ErwyDyfMvpDDPxGQq5xKMFFnKoZrmIE4j7VCYJE5P5GxOM2ahG7z/xAAcEQABBQADAAAAAAAAAAAAAAAAAQIQETESQVH/2gAIAQIBAT8AWOI8bpS+mmKXDuiz/8QAHBEAAgICAwAAAAAAAAAAAAAAAAECIRAREjFB/9oACAEDAQE/AFmBJVs2dWO4XXXXXX==",
                                        "scansSidecar": "z2GjaLAa4nTTkx/3SLpa1dyvSoeMAuSRw2VdmMuLZS1XJ5oiXXXX==",
                                        "scanLengths": [
                                                15301,
                                                33951,
                                                21529,
                                                36025
                                        ],
                                        "midQualityFileSha256": "4gWwuJi9etChm8FDU+Ih+n/EvlMRqtj2+/874XXXX=",
                                        "viewOnce": true
                                }
                        }
                }
        },
        "messageTimestamp": 1625237854,
        "ephemeralOutOfSync": false
}

Type : Buttons

 {
        "key": {
                "remoteJid": "6281XXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "3657593695CC54XXXX"
        },
        "message": {
                "buttonsMessage": {
                        "contentText": "Click this OK button to continue",
                        "footerText": "",
                        "buttons": [
                                {
                                        "buttonId": "buttonID",
                                        "buttonText": {
                                                "displayText": "👉 OK"
                                        },
                                        "type": 1
                                }
                        ],
                        "headerType": 1,
                        "Header": null
                }
        },
        "messageTimestamp": 1625650057,
        "ignore": true,
        "ephemeralOutOfSync": false
}

Type : List

{
        "key": {
                "remoteJid": "6281XXXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "BF47D8A4701A4XXXXX"
        },
        "message": {
                "listMessage": {
                        "title": "List of Menu",
                        "description": "Please select the menu you want",
                        "buttonText": "Delicious Menu",
                        "listType": 1,
                        "sections": [
                                {
                                        "title": "Pasta",
                                        "rows": [
                                                {
                                                        "title": "Ravioli Lasagna",
                                                        "description": "Made with layers of frozen cheese",
                                                        "rowId": "ravioli"
                                                }
                                        ]
                                },
                                {
                                        "title": "Dessert",
                                        "rows": [
                                                {
                                                        "title": "Baked Ricotta Cake",
                                                        "description": "Sweets pecan baklava rolls",
                                                        "rowId": "dessert1"
                                                },
                                                {
                                                        "title": "Lemon Meringue Pie",
                                                        "description": "Pastry filled with lemonand meringue.",
                                                        "rowId": "dessert2"
                                                }
                                        ]
                                }
                        ]
                }
        },
        "messageTimestamp": 1625651225,
        "ignore": true,
        "ephemeralOutOfSync": false
}
Ased2235 commented 3 years ago

I received a message like this, but it's not handled by this library yet

Type : View Once

        "key": {
                "remoteJid": "XXXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "A470D6994B1530XXXXXXXXXXXXX"
        },
        "message": {
                "viewOnceMessage":  {
                        "message": {
                                "imageMessage": {
                                        "url": "https://mmg.whatsapp.net/d/f/Ah5DkItASZpe5kUS3wFl5TB-eCvybMyNUXXXXXXXX.enc",
                                        "mimetype": "image/jpeg",
                                        "fileSha256": "Py5CDbVCO0NiKEgpQ1qwc2R5wrCdoXXXXXXXXX=",
                                        "fileLength": 106806,
                                        "height": 1600,
                                        "width": 900,
                                        "mediaKey": "IS3KOQrMdfHGO60bFOOSIDvRUIkxfXXXXXXXI=",
                                        "fileEncSha256": "6amXOE72esSpdQ8h+Hj/TtC8Y6OnOr4uQXXXXXX=",
                                        "directPath": "/v/t62.7118-24/35319310_307390284455166_584405XXXXXXXXX.enc?ccb=11-4\u0026oh=887417f31d720b7326143fXXXXXXX\u0026oe=60E5BXXXX",
                                        "mediaKeyTimestamp": 1625237853,
                                        "jpegThumbnail": "/9j/4AAQSkZJRgABAQAAAQABAAD/2wCEABsbGxscGx4hIR4qLSgtKj04MzM4PV1CR0JHQl2NWGdYWGdYjX2Xe3N7l33gsJycsOD/2c7Z//////////////8BGxsbGxwbHiEhHiotKC0qPTgzMzg9XUJHQkdCXY1YZ1hYZ1iNfZd7c3uXfeCwnJyw4P/Zztn////////////////CABEIAD4AIwMBIgACEQEDEQH/xAAvAAACAwEBAAAAAAAAAAAAAAADBAACBQEGAQADAQAAAAAAAAAAAAAAAAABAgMA/9oADAMBAAIQAxAAAACiT6Lgih1RtOPxhcNKZw0011IpaUmudrODPg67OiUFLQ06dOlPObWc8DmzTm3/xAAlEAACAgIBAwMFAAAAAAAAAAABAgADERIEFDFBEyFRIjIzYXH/2gAIAQEAAT8A0qI+wRq0dtUTH7no1IMEZaOoFmJ0NRA7ypS2T4EK22MzKIlhB0eWE7nJlHvSn8gCiooO2JToq4M5lRdxosTiLcjhva1ZxuZTTUEfOwlFuwhodrgVOFhcIMTL77p37GHihyWNYyYN6WwZ1GCDmArYdg05AddSoIUH3MHL1GGQ5j1bkk/EvpAnDvqVNPMbFqEGdQtf0P3ErwyDyfMvpDDPxGQq5xKMFFnKoZrmIE4j7VCYJE5P5GxOM2ahG7z/xAAcEQABBQADAAAAAAAAAAAAAAAAAQIQETESQVH/2gAIAQIBAT8AWOI8bpS+mmKXDuiz/8QAHBEAAgICAwAAAAAAAAAAAAAAAAECIRAREjFB/9oACAEDAQE/AFmBJVs2dWO4XXXXXX==",
                                        "scansSidecar": "z2GjaLAa4nTTkx/3SLpa1dyvSoeMAuSRw2VdmMuLZS1XJ5oiXXXX==",
                                        "scanLengths": [
                                                15301,
                                                33951,
                                                21529,
                                                36025
                                        ],
                                        "midQualityFileSha256": "4gWwuJi9etChm8FDU+Ih+n/EvlMRqtj2+/874XXXX=",
                                        "viewOnce": true
                                }
                        }
                }
        },
        "messageTimestamp": 1625237854,
        "ephemeralOutOfSync": false
}

Type : Buttons

 {
        "key": {
                "remoteJid": "6281XXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "3657593695CC54XXXX"
        },
        "message": {
                "buttonsMessage": {
                        "contentText": "Click this OK button to continue",
                        "footerText": "",
                        "buttons": [
                                {
                                        "buttonId": "buttonID",
                                        "buttonText": {
                                                "displayText": "👉 OK"
                                        },
                                        "type": 1
                                }
                        ],
                        "headerType": 1,
                        "Header": null
                }
        },
        "messageTimestamp": 1625650057,
        "ignore": true,
        "ephemeralOutOfSync": false
}

Type : List

{
        "key": {
                "remoteJid": "6281XXXXXXX@s.whatsapp.net",
                "fromMe": false,
                "id": "BF47D8A4701A4XXXXX"
        },
        "message": {
                "listMessage": {
                        "title": "List of Menu",
                        "description": "Please select the menu you want",
                        "buttonText": "Delicious Menu",
                        "listType": 1,
                        "sections": [
                                {
                                        "title": "Pasta",
                                        "rows": [
                                                {
                                                        "title": "Ravioli Lasagna",
                                                        "description": "Made with layers of frozen cheese",
                                                        "rowId": "ravioli"
                                                }
                                        ]
                                },
                                {
                                        "title": "Dessert",
                                        "rows": [
                                                {
                                                        "title": "Baked Ricotta Cake",
                                                        "description": "Sweets pecan baklava rolls",
                                                        "rowId": "dessert1"
                                                },
                                                {
                                                        "title": "Lemon Meringue Pie",
                                                        "description": "Pastry filled with lemonand meringue.",
                                                        "rowId": "dessert2"
                                                }
                                        ]
                                }
                        ]
                }
        },
        "messageTimestamp": 1625651225,
        "ignore": true,
        "ephemeralOutOfSync": false
}

Yo, can you upload screen shots of those messages along with how they're respond If user select item from list or button?

Ased2235 commented 3 years ago

I tried to adding View Once message type but i'm getting this error

panic: mismatching message name: got proto.SendPaymentMessage, want proto.ViewOnceMessage

goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.legacyLoadMessageDesc(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0x0, 0x40dd00)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:146 +0x8ab
google.golang.org/protobuf/internal/impl.legacyLoadMessageInfo(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0xa62d0cd1000ae8f0)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:58 +0xbd
google.golang.org/protobuf/internal/impl.legacyLoadMessageType(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0x1117900, 0xc000113f60)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:42 +0xfa
google.golang.org/protobuf/internal/impl.Export.LegacyMessageTypeOf(0x15874a0, 0x0, 0x1309f99, 0x15, 0x1261360, 0xc0002ad8c0)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_export.go:33 +0xa5
github.com/golang/protobuf/proto.RegisterType(0x15874a0, 0x0, 0x1309f99, 0x15)
        /home/_/bot/go-bot/src/github.com/golang/protobuf/proto/registry.go:180 +0x4d
github.com/Rhymen/go-whatsapp/binary/proto.init.0()
        /home/_/bot/go-bot/src/github.com/Rhymen/go-whatsapp/binary/proto/def.pb.go:6132 +0x933
exit status 2

def.pb.go:6132 proto.RegisterType((*ViewOnceMessage)(nil), "proto.ViewOnceMessage")

As far i understand it's the issues with protobuf and idk how to generate those can you help me out? @beshoo @Romerito007

Romerito007 commented 3 years ago

I tried to adding View Once message type but i'm getting this error

panic: mismatching message name: got proto.SendPaymentMessage, want proto.ViewOnceMessage

goroutine 1 [running]:
google.golang.org/protobuf/internal/impl.legacyLoadMessageDesc(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0x0, 0x40dd00)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:146 +0x8ab
google.golang.org/protobuf/internal/impl.legacyLoadMessageInfo(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0xa62d0cd1000ae8f0)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:58 +0xbd
google.golang.org/protobuf/internal/impl.legacyLoadMessageType(0x15a1dc0, 0x1251780, 0x1309f99, 0x15, 0x1117900, 0xc000113f60)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_message.go:42 +0xfa
google.golang.org/protobuf/internal/impl.Export.LegacyMessageTypeOf(0x15874a0, 0x0, 0x1309f99, 0x15, 0x1261360, 0xc0002ad8c0)
        /home/_/bot/go-bot/src/google.golang.org/protobuf/internal/impl/legacy_export.go:33 +0xa5
github.com/golang/protobuf/proto.RegisterType(0x15874a0, 0x0, 0x1309f99, 0x15)
        /home/_/bot/go-bot/src/github.com/golang/protobuf/proto/registry.go:180 +0x4d
github.com/Rhymen/go-whatsapp/binary/proto.init.0()
        /home/_/bot/go-bot/src/github.com/Rhymen/go-whatsapp/binary/proto/def.pb.go:6132 +0x933
exit status 2

def.pb.go:6132 proto.RegisterType((*ViewOnceMessage)(nil), "proto.ViewOnceMessage")

As far i understand it's the issues with protobuf and idk how to generate those can you help me out? @beshoo @Romerito007

Update protobuf has a commit https://github.com/Rhymen/go-whatsapp/pull/567

Ased2235 commented 3 years ago

View Once image

List image image

Button And as always, it didn't work image image

@Romerito007 Thanks a lot

Romerito007 commented 2 years ago

View Once image

List image image

Button And as always, it didn't work image image

@Romerito007 Thanks a lot

Sensational 🎉🎉

Ased2235 commented 2 years ago

View Once image List image image Button And as always, it didn't work image image @Romerito007 Thanks a lot

Sensational

Thanks for your help!

hrizal commented 2 years ago

Additional info :

ListMessage

Title: type is text only max length 60 char, title is optional.

Body: Type is only text, max length is 1024 char, body is mandatory.

Footer: Type is only text, max length 60 char. footer is optional

Section: title of section maximum length is 24 char.

Rows: (part of each section) id should be unique and max length is 200 char, mandatory, not appears on recipient but exist on raw data. title max length is 24 char, mandatory, appears on recipient description maximum is 72 char, optional, appears on recipient total for rows in listmessage max is 10 rows

beshoo commented 2 years ago

Can you please improve the PL, by adding the validation?

Regard

On Sun, Jul 11, 2021, 5:18 PM Rizal @.***> wrote:

Additional info :

ListMessage

Header: type of header actually can be : text or video or image or document (need set of type), max length of text for header is 60 char, header is optional.

Body: Type is only text, max length is 1024 char, body is mandatory.

Footer: Type is only text, max length 60 char.

Section: title of section maximum length is 24 char.

Rows: (part of each section) id should be unique and max length is 200 char, mandatory, not appears on recipient but exist on raw data. title max length is 24 char, mandatory, appears on recipient description maximum is 72 char, optional, appears on recipient

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/Rhymen/go-whatsapp/issues/588#issuecomment-877807964, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABDLT24N73AJKGRRGZC7NDLTXGR4JANCNFSM47W4XB4Q .

Ased2235 commented 2 years ago

Additional info :

ListMessage

Header: type of header actually can be : text or video or image or document (need set of type), max length of text for header is 60 char, header is optional.

Body: Type is only text, max length is 1024 char, body is mandatory.

Footer: Type is only text, max length 60 char. footer is optional

Section: title of section maximum length is 24 char.

Rows: (part of each section) id should be unique and max length is 200 char, mandatory, not appears on recipient but exist on raw data. title max length is 24 char, mandatory, appears on recipient description maximum is 72 char, optional, appears on recipient total for rows in listmessage max is 10 rows

Can you send Listmessage json with header? as far i can see it doesn't have header value

hrizal commented 2 years ago

ah ... i am sorry 🤭, type header of listmessage is text only. and header is title on json