I've the below code:
package utils
import (
"context"
"strconv"
"wa/Enum"
"wa/api"
"wa/global"
waProto "go.mau.fi/whatsmeow/binary/proto"
"google.golang.org/protobuf/proto"
)
func MainMenu(sender, welcome string) {
msg := &waProto.ListMessage{
Title: proto.String(welcome),
Description: proto.String("يرجى تحديد سبب التواصل"),
ButtonText: proto.String("أنقر هنا 👈"),
ListType: waProto.ListMessage_SINGLE_SELECT.Enum(),
Sections: []*waProto.ListMessage_Section{
{
Title: proto.String("لدي إستفسار بخصوص:"),
Rows: []*waProto.ListMessage_Row{
{
RowId: proto.String(strconv.Itoa(Enum.Discount)),
Title: proto.String("عمادة القبول والتسجيل"),
},
{
RowId: proto.String(strconv.Itoa(Enum.Discount)),
Title: proto.String("عمادة شؤون المكتبات"),
},
{
RowId: proto.String(strconv.Itoa(Enum.Discount)),
Title: proto.String("مواقع كليات وفروع جامعة الملك خالد"),
},
},
},
},
}
targetJID, ok := ParseJID(sender)
if !ok {
return
}
send, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
ListMessage: msg,
}) // jid = recipient
if err != nil {
global.Log.Errorf("Error sending message: %v", err)
} else {
global.Log.Infof("Message sent (server timestamp: %s)", send)
}
send2, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
Conversation: proto.String("Hello, World!"),
})
if err != nil {
global.Log.Errorf("Error sending message: %v", err)
} else {
global.Log.Infof("Message sent (server timestamp: %s)", send2)
}
}
But the list message is seen only at th esender account (i.e. the account connected to the app using whatsmeow package) and not seeing it at the recieved account, same happen with Button Message
, but sending a conversation message
is different as it is appearing at both accounts
msg := &waProto.ButtonsMessage{
ContentText: proto.String("لدي إستفسار بخصوص:"),
HeaderType: waProto.ButtonsMessage_EMPTY.Enum(),
Buttons: []*waProto.ButtonsMessage_Button{
{
ButtonId: proto.String(strconv.Itoa(Enum.Yes)),
ButtonText: &waProto.ButtonsMessage_Button_ButtonText{DisplayText: proto.String("نعم")},
Type: waProto.ButtonsMessage_Button_RESPONSE.Enum(),
NativeFlowInfo: &waProto.ButtonsMessage_Button_NativeFlowInfo{},
},
{
ButtonId: proto.String(strconv.Itoa(Enum.No)),
ButtonText: &waProto.ButtonsMessage_Button_ButtonText{DisplayText: proto.String("لا")},
Type: waProto.ButtonsMessage_Button_RESPONSE.Enum(), //proto.ButtonsMessage_Button_Type.Enum,
NativeFlowInfo: &waProto.ButtonsMessage_Button_NativeFlowInfo{},
},
},
}
send, err := api.Client.SendMessage(context.Background(), targetJID, "", &waProto.Message{
ButtonsMessage: msg,
})