tulir / whatsmeow

Go library for the WhatsApp web multidevice API

Home Page:https://go.mau.fi/whatsmeow

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to reply a group message

GonzalezAtWork opened this issue · comments

Hello guys!

I am a bit lost and did not found a reply on google or here on how can I reply a Group Message?

I can still use SendMessage, creating a JID from the group, instead of a specifc user?

some directions, please?

thanks!

You can send a message (SendMessage) into where the chat (jid) coming from.
Chat evt.Info.Chat, the Sender evt.Info.Sender.

// MessageSource contains basic sender and chat information about a message.
type MessageSource struct {
Chat JID // The chat where the message was sent.
Sender JID // The user who sent the message.
IsFromMe bool // Whether the message was sent by the current user instead of someone else.
IsGroup bool // Whether the chat is a group chat or broadcast list.

None of those did not worked:

chatJid = types.NewJID(v.Info.Chat, types.DefaultUserServer)

chatJid = types.NewJID(v.Info.Chat.User, types.DefaultUserServer)

chatJid = types.NewJID(v.Info.Chat.Server, types.DefaultUserServer)

This do not give an error, but also did not send any response to the chat:

chatJid = types.NewJID(v.Info.Chat.User +"@" + v.Info.Chat.Server, types.DefaultUserServer)

(ends up with ID@g.us@s.whatsapp.net)

mycli.WAClient.SendMessage(context.Background(), chatJid, response)

You're way overthinking things

chatJid = v.Info.Chat

Maybe need new IDE for editing the code that support LSP.

ops, my bad:

chatJid = types.NewJID(v.Info.Chat.User, v.Info.Chat.Server)
this works

but nice to know that there is a simplier solution like you said! Thanks!

ops, my bad:

chatJid = types.NewJID(v.Info.Chat.User, v.Info.Chat.Server) this works

but nice to know that there is a simplier solution like you said! Thanks!

Actually, v.Info.Chat is already types.JID and doesn't need to be re-created it.