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

UpdateGroupParticipants 403 error #441

Open
ronaldotantra opened this issue Aug 9, 2023 · 3 comments
Open

UpdateGroupParticipants 403 error #441

ronaldotantra opened this issue Aug 9, 2023 · 3 comments

Comments

@ronaldotantra
Copy link

ronaldotantra commented Aug 9, 2023

got error 403 when calling UpdateGroupParticipants type ParticipantChangeAdd

my account is already admin on the group
but i can invite them manually from my phone

@ronaldotantra
Copy link
Author

        message := ""
	if evt.Message.GetConversation() != "" {
		message = evt.Message.GetConversation()
	}

	words := strings.Split(message, " ")
	data := strings.Split(words[1], "\n")
	groupId := data[0]
	groupJID := types.JID{
		User:   groupId,
		Server: types.GroupServer,
	}
	numbers := data[1:]
	invalid := []string{}
	for _, n := range numbers {
		jids := map[types.JID]whatsmeow.ParticipantChange{}
		if strings.HasPrefix(n, "08") {
			n = strings.Replace(n, "08", "628", 1)
		}
		jids[types.JID{
			User:   n,
			Server: types.DefaultUserServer,
		}] = whatsmeow.ParticipantChangeAdd
		x, err := a.client.UpdateGroupParticipants(groupJID, jids)
		if err != nil {
			return err
		}
		c := x.GetChildrenByTag("add")
		c = c[0].GetChildrenByTag("participant")
		if c == nil {
			continue
		}
		c1 := c[0].Attrs["error"]
		if c1 == nil {
			continue
		}
		v := c1.(string)

		if v == "403" {
			invalid = append(invalid, n)
		}
	}
	c := strings.Join(invalid, "\n")
	msg := &whatsmeow_proto.Message{
		Conversation: &c,
	}
	_, err := a.client.SendMessage(ctx, evt.Info.Chat, msg)
	if err != nil {
		return err
	}

	return nil

@ronaldotantra
Copy link
Author

example of message

!invite groupid
0811231231
0811231234
0811231233
0811231234

@arugaz
Copy link
Contributor

arugaz commented Nov 20, 2023

You can send GroupInviteMessage

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