Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to reply a group message #585

Closed
GonzalezAtWork opened this issue May 11, 2024 · 6 comments
Closed

How to reply a group message #585

GonzalezAtWork opened this issue May 11, 2024 · 6 comments

Comments

@GonzalezAtWork
Copy link

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!

@JustSoursop
Copy link

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.

@GonzalezAtWork
Copy link
Author

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)

@tulir
Copy link
Owner

tulir commented May 12, 2024

You're way overthinking things

chatJid = v.Info.Chat

@tulir tulir closed this as completed May 12, 2024
@JustSoursop
Copy link

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

@GonzalezAtWork
Copy link
Author

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!

@JustSoursop
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants