Created
September 10, 2020 03:25
Revisions
-
dev4Fun created this gist
Sep 10, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ import logging from abc import abstractmethod from tracker import post_tracker from utils import rand_wait_min logger = logging.getLogger() class BotRunningStrategy: @abstractmethod def should_continue_run(self): pass class RunForeverStrategy(BotRunningStrategy): def should_continue_run(self): return True class LikeLimitStrategy(BotRunningStrategy): def __init__(self, limit=200): super().__init__() self.limit = limit def should_continue_run(self): return post_tracker.liked_count < self.limit class RunForeverWithBreaks(LikeLimitStrategy): def should_continue_run(self): if post_tracker.liked_count > 0 and post_tracker.liked_count % self.limit == 0: logger.info(f"Reached {self.limit} likes. Sleeping.. ") rand_wait_min(20, 30) return True