Go-whatsapp: Can't send stickers?

Created on 2 Aug 2020  路  15Comments  路  Source: Rhymen/go-whatsapp

well I was trying to send stickers the same way as the text, audio and image messages work but though these other types work, the sticker does not send. there's no error as well, just no response

Most helpful comment

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1
I am getting this error now.

You have to implement sending stickers

how do I do that??

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L26

Add this code within the function indicated on the line above.

case StickerMessage:
var err error
m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaImage)
if err != nil {
return "ERROR", fmt.Errorf("image upload failed: %v", err)
}
msgProto = getStickerMessageProto(m)

Add this code below in the function indicated in the line above.

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L738

`func getStickerMessageProto(msg StickerMessage) *proto.WebMessageInfo {
p := getInfoProto(&msg.Info)
contextInfo := getContextInfoProto(&msg.ContextInfo)

   p.Message = &proto.Message{
     StickerMessage: &proto.StickerMessage{
   Url:           &msg.url,
   MediaKey:      msg.mediaKey,
   Mimetype:      &msg.Type,
   FileEncSha256: msg.fileEncSha256,
   FileSha256:    msg.fileSha256,
   FileLength:    &msg.fileLength,
   ContextInfo:   contextInfo,
  }
  return p

}`

Ah thanks man, I now understand how it works. Much appreciated.
The last code will have an extra }, before the } above the return p. That's all I had to do.

Thanks again

All 15 comments

Can we send this type via chrome.?

Can we send this type via chrome.?

by in chrome what do you mean? like using the console? i have not tried sending stickers that are stored locally from there

To send stickers the type has to be stikers.webp

`type StickerMessage struct {
Info MessageInfo

Type          string
Content       io.Reader
url           string
mediaKey      []byte
fileEncSha256 []byte
fileSha256    []byte
fileLength    uint64

ContextInfo ContextInfo

}`

`func getStickerMessage(msg *proto.WebMessageInfo) StickerMessage {
sticker := msg.GetMessage().GetStickerMessage()

stickerMessage := StickerMessage{
    Info:          getMessageInfo(msg),
    url:           sticker.GetUrl(),
    mediaKey:      sticker.GetMediaKey(),
    Type:          sticker.GetMimetype(),
    fileEncSha256: sticker.GetFileEncSha256(),
    fileSha256:    sticker.GetFileSha256(),
    fileLength:    sticker.GetFileLength(),
    ContextInfo:   getMessageContext(sticker.GetContextInfo()),
}

return stickerMessage

}`

`func getStickerMessageProto(msg StickerMessage) *proto.WebMessageInfo {
p := getInfoProto(&msg.Info)
contextInfo := getContextInfoProto(&msg.ContextInfo)

p.Message = &proto.Message{
    StickerMessage: &proto.StickerMessage{
        Url:           &msg.url,
        MediaKey:      msg.mediaKey,
        Mimetype:      &msg.Type,
        FileEncSha256: msg.fileEncSha256,
        FileSha256:    msg.fileSha256,
        FileLength:    &msg.fileLength,
        ContextInfo:   contextInfo,
    },
}
return p

}`

func (m *StickerMessage) Download() ([]byte, error) { return Download(m.url, m.mediaKey, MediaImage, int(m.fileLength)) }

case msg.GetMessage().GetStickerMessage() != nil: return getStickerMessage(msg)

case StickerMessage: var err error m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaImage) if err != nil { return "ERROR", fmt.Errorf("image upload failed: %v", err) } msgProto = getStickerMessageProto(m)

To send stickers the type has to be stikers.webp
So the type will be stikers.webp and not image/webp ?

To send stickers the type has to be stikers.webp
So the type will be stikers.webp and not image/webp ?

It's image/webp

Can we send this type via chrome.?

Yes it's possible now, it's added next to emoji button

Para enviar adesivos, o tipo deve ser stikers.webp.
Ent茫o, o tipo ser谩 stikers.webp e n茫o image / webp?

mime type image/webp

content := whatsapp.StickerMessage{ Info: whatsapp.MessageInfo{ RemoteJid: Jid, Id: Id, }, Type: "image/webp", Content: msgFile, }

To send stickers the type has to be stikers.webp
So the type will be stikers.webp and not image/webp ?

It's image/webp

`ole,err = os.Open("index.webp")

wac.Send(whatsapp.StickerMessage{
Info: whatsapp.MessageInfo{
RemoteJid: message.Info.RemoteJid,
},
Type: "image/webp",
Content: ole,
})`

I've written this but it doesn't work. Could you take a look at it and tell me what's wrong??

To send stickers the type has to be stikers.webp
So the type will be stikers.webp and not image/webp ?

It's image/webp

`ole,err = os.Open("index.webp")

wac.Send(whatsapp.StickerMessage{
Info: whatsapp.MessageInfo{
RemoteJid: message.Info.RemoteJid,
},
Type: "image/webp",
Content: ole,
})`

I've written this but it doesn't work. Could you take a look at it and tell me what's wrong??

Is there any error? Does the file exist? I'm using it & it's working fine

To send stickers the type has to be stikers.webp
So the type will be stikers.webp and not image/webp ?

It's image/webp

ole,err = os.Open("index.webp") wac.Send(whatsapp.StickerMessage{ Info: whatsapp.MessageInfo{ RemoteJid: message.Info.RemoteJid, }, Type: "image/webp", Content: ole, })
I've written this but it doesn't work. Could you take a look at it and tell me what's wrong??

Is there any error? Does the file exist? I'm using it & it's working fine

Oh it's working? I have a file called index.webp in the folder where the script is placed along with other images and audios which I have no problem in sending. Only the sticker doesn't work

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1

I am getting this error now.

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1

I am getting this error now.

You have to implement sending stickers

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1
I am getting this error now.

You have to implement sending stickers

how do I do that??

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1
I am getting this error now.

You have to implement sending stickers

how do I do that??

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L26

Add this code within the function indicated on the line above.

case StickerMessage:
var err error
m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaImage)
if err != nil {
return "ERROR", fmt.Errorf("image upload failed: %v", err)
}
msgProto = getStickerMessageProto(m)

Add this code below in the function indicated in the line above.

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L738

`func getStickerMessageProto(msg StickerMessage) *proto.WebMessageInfo {
p := getInfoProto(&msg.Info)
contextInfo := getContextInfoProto(&msg.ContextInfo)

   p.Message = &proto.Message{
     StickerMessage: &proto.StickerMessage{
     Url:           &msg.url,
     MediaKey:      msg.mediaKey,
     Mimetype:      &msg.Type,
     FileEncSha256: msg.fileEncSha256,
     FileSha256:    msg.fileSha256,
     FileLength:    &msg.fileLength,
     ContextInfo:   contextInfo,
  }
  return p

}`

error sending message: cannot match type whatsapp.StickerMessage, use message types declared in the packageexit status 1
I am getting this error now.

You have to implement sending stickers

how do I do that??

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L26

Add this code within the function indicated on the line above.

case StickerMessage:
var err error
m.url, m.mediaKey, m.fileEncSha256, m.fileSha256, m.fileLength, err = wac.Upload(m.Content, MediaImage)
if err != nil {
return "ERROR", fmt.Errorf("image upload failed: %v", err)
}
msgProto = getStickerMessageProto(m)

Add this code below in the function indicated in the line above.

https://github.com/Rhymen/go-whatsapp/blob/master/message.go#L738

`func getStickerMessageProto(msg StickerMessage) *proto.WebMessageInfo {
p := getInfoProto(&msg.Info)
contextInfo := getContextInfoProto(&msg.ContextInfo)

   p.Message = &proto.Message{
     StickerMessage: &proto.StickerMessage{
   Url:           &msg.url,
   MediaKey:      msg.mediaKey,
   Mimetype:      &msg.Type,
   FileEncSha256: msg.fileEncSha256,
   FileSha256:    msg.fileSha256,
   FileLength:    &msg.fileLength,
   ContextInfo:   contextInfo,
  }
  return p

}`

Ah thanks man, I now understand how it works. Much appreciated.
The last code will have an extra }, before the } above the return p. That's all I had to do.

Thanks again

Was this page helpful?
0 / 5 - 0 ratings

Related issues

anton-rs picture anton-rs  路  10Comments

Manjit2003 picture Manjit2003  路  9Comments

yazeed44 picture yazeed44  路  4Comments

jhow2892 picture jhow2892  路  3Comments

denislee picture denislee  路  6Comments