Skip to content

Commit

Permalink
closes #107
Browse files Browse the repository at this point in the history
  • Loading branch information
SchulteMK committed Mar 5, 2019
1 parent e49d1c0 commit fe9b68a
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions group.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,3 +63,28 @@ func (wac *Conn) GroupInviteLink(jid string) (string, error) {

return response["code"].(string), nil
}

func (wac *Conn) GroupAcceptInviteCode(code string) (jid string, err error) {
request := []interface{}{"action", "invite", code}
ch, err := wac.write(request)
if err != nil {
return "", err
}

var response map[string]interface{}

select {
case r := <-ch:
if err := json.Unmarshal([]byte(r), &response); err != nil {
return "", fmt.Errorf("error decoding response message: %v\n", err)
}
case <-time.After(wac.msgTimeout):
return "", fmt.Errorf("request timed out")
}

if int(response["status"].(float64)) != 200 {
return "", fmt.Errorf("request responded with %d", response["status"])
}

return response["gid"].(string), nil
}

5 comments on commit fe9b68a

@yusup209
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i call this function, it returns an error : "request responded with %!d(float64=406)" a.k.a. responded with HTTP 406 error

@Ased2235
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when i call this function, it returns an error : "request responded with %!d(float64=406)" a.k.a. responded with HTTP 406 error

How are you calling it? Group link or invitation?

@yusup209
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

group link

@Ased2235
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to send ID only not the link, for example
https://chat.whatsapp.com/EKTahlnDy9dL6Vifuregn3
To
EKTahlnDy9dL6Vifuregn3

@yusup209
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks

Please sign in to comment.