File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -127,14 +127,24 @@ has pending_timeouts => (
127127async sub connect ($self ) {
128128 $self -> connected(0);
129129
130- my $res = await $self -> hub-> http_client-> GET(
131- " https://slack.com/api/rtm.connect?token=" . $self -> api_key
132- );
130+ my $json ;
133131
134- my $json = decode_json($res -> content);
132+ until ($json ) {
133+ my $res = await $self -> hub-> http_client-> GET(
134+ " https://slack.com/api/rtm.connect?token=" . $self -> api_key
135+ );
135136
136- die " Could not connect to Slack RTM: $json ->{error}"
137- unless $json -> {ok };
137+ if ($res -> code == 429) {
138+ $Logger -> log (' received 429 while connecting to Slack; will try again in 120s' );
139+ await $self -> loop-> delay_future(after => 120);
140+ next ;
141+ }
142+
143+ my $json = decode_json($res -> content);
144+
145+ die " Could not connect to Slack RTM: $json ->{error}"
146+ unless $json -> {ok };
147+ }
138148
139149 # This is a dumb hack: when I converted synergy to a Slack app, I gave her
140150 # perms to add a user with the name "synergee" because I thought "synergy"
You can’t perform that action at this time.
0 commit comments