protect.py 450 B

123456789101112131415161718
  1. import random
  2. from time import sleep
  3. from module.logger import logger
  4. def random_delay(min_value: float = 2.0, max_value: float = 6.0, decimal: int = 1):
  5. """
  6. 防封
  7. """
  8. random_float_in_range = random.uniform(min_value, max_value)
  9. sleep(round(random_float_in_range, decimal))
  10. def random_sleep(probability: float = 0.05):
  11. if random.random() <= probability:
  12. logger.info('Tigger random sleep')
  13. random_delay()