AmarnathCJD / gogram

Full-native implementation of MTProto protocol on Golang.
GNU General Public License v3.0
191 stars 37 forks source link

Error FLOOD_PREMIUM_WAIT_X not handled #117

Closed Ivanezko closed 1 month ago

Ivanezko commented 1 month ago

Describe the bug If user has a premium, flood protection during media download sends him not only "FLOODWAIT(\d+)" errors but sometimes "FLOOD_PREMIUMWAIT(\d+)". As long this error is not handled - the whole download process stops forever.

Example

2024/07/26 08:14:07 logging.go:105: [debug] gogram [mtproto] - downloading part 417/1232 in chunks of 1024
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood error: sending UploadGetFile: [FLOOD_PREMIUM_WAIT_14] FLOOD_PREMIUM_WAIT_14 (code 420)
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood wait 14s waiting...
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood error: sending UploadGetFile: [FLOOD_PREMIUM_WAIT_14] FLOOD_PREMIUM_WAIT_14 (code 420)
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood wait 14s waiting...
2024/07/26 08:14:07 logging.go:105: [debug] gogram [mtproto] - downloading part 418/1232 in chunks of 1024
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood error: sending UploadGetFile: [FLOOD_PREMIUM_WAIT_14] FLOOD_PREMIUM_WAIT_14 (code 420)
2024/07/26 08:14:07 logging.go:93: [warn] gogram [mtproto] - flood wait 14s waiting...

Additional context An example of fix in telegram/utils.go

func getFloodWait(err error) time.Duration {
    if err != nil {
        // FLOOD_PREMIUM_WAIT_X
        if re := regexp.MustCompile(`FLOOD_PREMIUM_WAIT_(\d+)`); re.MatchString(err.Error()) {
            wait, _ := strconv.Atoi(re.FindStringSubmatch(err.Error())[1])
            return time.Duration(wait) * time.Second
        } else if re := regexp.MustCompile(`A wait of (\d+) seconds is required`); re.MatchString(err.Error()) {
            wait, _ := strconv.Atoi(re.FindStringSubmatch(err.Error())[1])
            return time.Duration(wait) * time.Second
        } else if re := regexp.MustCompile(`FLOOD_WAIT_(\d+)`); re.MatchString(err.Error()) {
            wait, _ := strconv.Atoi(re.FindStringSubmatch(err.Error())[1])
            return time.Duration(wait) * time.Second
        }
    }
    return 0
}
AmarnathCJD commented 1 month ago

👍🏼

itzrexmodz commented 1 month ago

@AmarnathCJD owner doesn't have a premium telegram account to fix bugs, so it would be nice of you to gift him telegram premium xD.

His ID t.me/ItzAditya_xD

AmarnathCJD commented 1 month ago

@AmarnathCJD owner doesn't have a premium telegram account to fix bugs, so it would be nice of you to gift him telegram premium xD.

His ID t.me/ItzAditya_xD

U scam scam 🤡👍🏼 u donate me @RoseLoverX

Ivanezko commented 1 month ago

nice try! but the code example should be enough :)

AmarnathCJD commented 1 month ago

nice try! but the code example should be enough :)

😹😹 Yeah

AmarnathCJD commented 1 month ago

nice try! but the code example should be enough :)

Just starring the repo will be enough