From 7dd92059d6b8848c7a2d16b4adbc0b3857d75ecb Mon Sep 17 00:00:00 2001 From: "kyoshiro.maruo" Date: Thu, 24 Jun 2021 10:59:33 +0900 Subject: [PATCH] get conversation: change limit parameter and retry for rate limit --- api.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/api.go b/api.go index 0ae5002..6e820a0 100644 --- a/api.go +++ b/api.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "time" "github.com/slack-go/slack" ) @@ -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...)