Replies: 2 comments
-
It is sounds strange. I was never facing this issue since the first time using whatsmeow. Even when running with outdated protobuf. Currently, whatsmeow is using waE2E the newest protocol. recipient, ok := parseJID("<number>@<server>")
if !ok {
// panic
}
msg := &waE2E.Message{Conversation: proto.String(strings.Join(args[1:], " "))}
resp, err := cli.SendMessage(context.Background(), recipient, msg)
if err != nil {
log.Errorf("Error sending message: %v", err)
} else {
log.Infof("Message sent (server timestamp: %s)", resp.Timestamp)
} I have use old one proto, but it is just fine. reff : |
Beta Was this translation helpful? Give feedback.
-
Regarding the deprecation, try using That's the updated one. Reference: https://pkg.go.dev/go.mau.fi/[email protected]/binary/proto#Message |
Beta Was this translation helpful? Give feedback.
-
Hi everyone,
First of all, thank you in advance for any help you can provide.
I've been working on a WhatsApp client using the WhatsMeow library. I've successfully configured the client and logged in to the WhatsApp Web account. However, I'm facing an issue when trying to send messages. The code I'm using is as follows:
`targetJID := types.NewJID("0087654321", types.DefaultUserServer)
message := &waProto.Message{
Conversation: proto.String("Test message!"),
}
resp, err := client.SendMessage(context.Background(), targetJID, message)
if err != nil {
fmt.Println("Error sending message:", err)
} else {
fmt.Println("Message sent, response:", resp)
}`
The problem is that instead of the message being sent to the desired number ("0087654321"), I receive the message on the logged-in number (the number associated with the WhatsApp Web session). To make things more confusing, it's as if the target number sent the message back to me.
For example, if I run this code intending to send "Test message!" to the target number "0087654321", what actually happens is that my logged-in number (let's say "0012345678") receives "Test message!" as if it was sent by "0087654321" to me.
Additionally, I received a warning that waProto is deprecated, which makes me question whether I'm using the correct dependencies for sending messages. Here are the dependencies I'm currently using:
_ "github.com/mattn/go-sqlite3" "github.com/mdp/qrterminal/v3" "go.mau.fi/whatsmeow" "go.mau.fi/whatsmeow/store/sqlstore" waLog "go.mau.fi/whatsmeow/util/log" waProto "go.mau.fi/whatsmeow/binary/proto" "go.mau.fi/whatsmeow/types" "google.golang.org/protobuf/proto"
Has anyone encountered a similar issue or have any insights on what might be going wrong? I'm also wondering if there's a more up-to-date or recommended way to send messages, considering the deprecation warning for waProto.
Any help or pointers would be greatly appreciated!
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions