From 9fd41e84054c5cd2129c649f48dc06d1cce4c4a6 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Tue, 23 Jul 2019 02:13:34 -0700 Subject: [PATCH] Limit number of autoretries on posting error. #1302 --- src/Posting/QR.coffee | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/src/Posting/QR.coffee b/src/Posting/QR.coffee index 2d541b43b..73d933791 100644 --- a/src/Posting/QR.coffee +++ b/src/Posting/QR.coffee @@ -775,19 +775,24 @@ QR = delete QR.currentCaptcha if err + QR.errorCount = (QR.errorCount or 0) + 1 if /captcha|verification/i.test(err.textContent) or connErr # Remove the obnoxious 4chan Pass ad. if /mistyped/i.test err.textContent err = 'You mistyped the CAPTCHA, or the CAPTCHA malfunctioned.' else if /expired/i.test err.textContent err = 'This CAPTCHA is no longer valid because it has expired.' - # Something must've gone terribly wrong if you get captcha errors without captchas. - # Don't auto-post indefinitely in that case. - QR.cooldown.auto = QR.captcha.isEnabled or connErr - # Too many frequent mistyped captchas will auto-ban you! - # On connection error, the post most likely didn't go through. - # If the post did go through, it should be stopped by the duplicate reply cooldown. - QR.cooldown.addDelay post, 2 + if QR.errorCount >= 5 + # Too many posting errors can ban you. Stop autoposting after 5 errors. + QR.cooldown.auto = false + else + # Something must've gone terribly wrong if you get captcha errors without captchas. + # Don't auto-post indefinitely in that case. + QR.cooldown.auto = QR.captcha.isEnabled or connErr + # Too many frequent mistyped captchas will auto-ban you! + # On connection error, the post most likely didn't go through. + # If the post did go through, it should be stopped by the duplicate reply cooldown. + QR.cooldown.addDelay post, 2 else if err.textContent and (m = err.textContent.match /(?:(\d+)\s+minutes?\s+)?(\d+)\s+second/i) and !/duplicate|hour/i.test(err.textContent) QR.cooldown.auto = !/have\s+been\s+muted/i.test(err.textContent) seconds = 60 * (+(m[1]||0)) + (+m[2]) @@ -802,6 +807,8 @@ QR = QR.error err return + delete QR.errorCount + h1 = $ 'h1', @response [_, threadID, postID] = h1.nextSibling.textContent.match /thread:(\d+),no:(\d+)/