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

Can't send invite member #462

Open
Ased2235 opened this issue Sep 9, 2023 · 1 comment
Open

Can't send invite member #462

Ased2235 opened this issue Sep 9, 2023 · 1 comment

Comments

@Ased2235
Copy link

Ased2235 commented Sep 9, 2023

i'm trying to add member using UpdateGroupParticipants everything works fine but if member set privately it won't work nor i got any error response.

IDs := make(map[types.JID]whatsmeow.ParticipantChange)
	IDs[user.JID] = whatsmeow.ParticipantChangeAdd

	gid, _ := parseJID(message.Info.RemoteJid)

	d, err := Was().UpdateGroupParticipants(gid, IDs)

	if err != nil {
		Log.Errorf("Error adding participants to group: %v", err)
		return
	}

		Log.Infof("Added participants to group: %v", (d.Join)) // -> res ["[email protected]"]
` 
@arugaz
Copy link
Contributor

arugaz commented Sep 24, 2023

you can send GroupInviteMessage, if the user set private

IDs := make(map[waTypes.JID]whatsmeow.ParticipantChange)
target, _ :=  waTypes.ParseJID(strings.Split(v.Message.GetConversation(), " ")[1]) // particicpant to add
IDs[target] = whatsmeow.ParticipantChangeAdd

mycli.WAClient.GetGroupInviteLink(v.Info.Chat,  false)

add, _ := mycli.WAClient.UpdateGroupParticipants(v.Info.Chat, IDs)
addTag := add.GetChildByTag("add")
rest := addTag.GetChildByTag("participant")
errorCode := rest.Attrs["error"].(string)
if errorCode == "403" {
  add_req := rest.GetChildByTag("add_request")
  code := add_req.Attrs["code"].(string)
  expCode  := add_req.Attrs["expiration"].(string)
  exp, _ := strconv.ParseInt(expCode, 10, 64)
  groupInfo, _ := mycli.WAClient.GetGroupInfo(v.Info.Chat)
  groupJid := v.Info.Chat.String()
  caption := "TEST WHATSMEOW"
  mycli.WAClient.SendMessage(context.Background(), target, &waProto.Message{
	GroupInviteMessage: &waProto.GroupInviteMessage{
		InviteCode: &code,
		InviteExpiration: &exp,
		GroupJid: &groupJid,
		GroupName: &groupInfo.Name,
		Caption: &caption,
		// JpegThumbnail: ,
       },
  },)
}

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

2 participants