Skip to content

Commit

Permalink
get conversation: change limit parameter and retry for rate limit
Browse files Browse the repository at this point in the history
  • Loading branch information
kyoshiro.maruo committed Jun 24, 2021
1 parent 6025ea4 commit 7dd9205
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 7dd9205

Please sign in to comment.