Include /r9k/ mute time in cooldowns. #535

This commit is contained in:
ccd0 2015-10-24 17:38:01 -07:00
parent 746e89bb06
commit 36da421396
2 changed files with 12 additions and 6 deletions

View File

@ -764,12 +764,13 @@ QR =
# Too many frequent mistyped captchas will auto-ban you! # Too many frequent mistyped captchas will auto-ban you!
# On connection error, the post most likely didn't go through. # On connection error, the post most likely didn't go through.
QR.cooldown.addDelay post, 2 QR.cooldown.addDelay post, 2
else if err.textContent and (m = err.textContent.match /wait\s+(\d+)\s+second/i) and !/duplicate/i.test err.textContent 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 = if QR.captcha.isEnabled QR.cooldown.auto = (!QR.captcha.isEnabled or !!QR.captcha.captchas.length) and !/have\s+been\s+muted/i.test(err.textContent)
!!QR.captcha.captchas.length seconds = 60 * (+(m[1]||0)) + (+m[2])
if /muted/i.test err.textContent
QR.cooldown.addMute seconds
else else
true QR.cooldown.addDelay post, seconds
QR.cooldown.addDelay post, +m[1]
QR.captcha.setup (d.activeElement is QR.nodes.status) QR.captcha.setup (d.activeElement is QR.nodes.status)
else # stop auto-posting else # stop auto-posting
QR.cooldown.auto = false QR.cooldown.auto = false

View File

@ -60,6 +60,11 @@ QR.cooldown =
QR.cooldown.set g.BOARD.ID, Date.now(), cooldown QR.cooldown.set g.BOARD.ID, Date.now(), cooldown
QR.cooldown.start() QR.cooldown.start()
addMute: (delay) ->
return unless Conf['Cooldown']
QR.cooldown.set g.BOARD.ID, Date.now(), {type: 'mute', delay}
QR.cooldown.start()
delete: (post) -> delete: (post) ->
return unless Conf['Cooldown'] return unless Conf['Cooldown']
$.forceSync 'cooldowns' $.forceSync 'cooldowns'
@ -121,7 +126,7 @@ QR.cooldown =
if cooldown.delay <= elapsed if cooldown.delay <= elapsed
delete cooldowns[start] delete cooldowns[start]
save.push scope save.push scope
else if cooldown.type is type and cooldown.threadID is threadID else if (cooldown.type is type and cooldown.threadID is threadID) or cooldown.type is 'mute'
# Delays only apply to the given post type and thread. # Delays only apply to the given post type and thread.
seconds = Math.max seconds, cooldown.delay - elapsed seconds = Math.max seconds, cooldown.delay - elapsed
continue continue