HTTP 420 · Flood
HTTP 420 Flood / Rate limits Parameterized

When & why it happens

The server is rate-limiting this operation. Sleep for the duration the server reports before retrying.

Parameterized error

The wire code carries a parameter on its tail (literal you'll see: FLOOD_TEST_PHONE_WAIT_42). Gogram parses it out and stores it on ErrResponseCode.AdditionalInfo with the right type.

Handling in gogram

Surfaced as *gogram.ErrResponseCode. Match on the message:

if err, ok := err.(*gogram.ErrResponseCode); ok { if strings.HasPrefix(err.Message, "FLOOD_TEST_PHONE_WAIT") { secs := err.AdditionalInfo.(int) time.Sleep(time.Duration(secs) * time.Second) // retry } }