Skip to content

Commit

Permalink
Merge pull request #86 from snowhork/fix-get-conversation-for-many-ch…
Browse files Browse the repository at this point in the history
…annels

Improve GetConversations API Call
  • Loading branch information
bcicen authored Jul 21, 2021
2 parents 6025ea4 + 7dd9205 commit 7af52a5
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions api.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package main

import (
"fmt"
"time"

"github.com/slack-go/slack"
)
Expand Down Expand Up @@ -91,9 +92,15 @@ func getConversations(types ...string) (list []slack.Channel, err error) {
Cursor: cursor,
ExcludeArchived: "true",
Types: types,
Limit: 1000,
}
channels, cur, err := api.GetConversations(param)
if err != nil {
if rateLimitedError, ok := err.(*slack.RateLimitedError); ok {
output(fmt.Sprintf("%v", rateLimitedError))
time.Sleep(rateLimitedError.RetryAfter)
continue
}
return list, err
}
list = append(list, channels...)
Expand Down

0 comments on commit 7af52a5

Please sign in to comment.