|
@@ -34,6 +34,11 @@ class Bot(object):
|
|
|
self.until = self.until.replace(hour=23, minute=59, second=59)
|
|
|
|
|
|
def _should_get_msg(self, account):
|
|
|
+ if self.debug_mode:
|
|
|
+ print("Filtering {}".format(account.username))
|
|
|
+ print("Created at: {}".format(account.created_at))
|
|
|
+ print("self.since_at is {}".format(self.since_at))
|
|
|
+ print("self.until is {}".format(self.until))
|
|
|
return account.url.startswith(self.instance_url) and account.created_at >= self.since_at and account.created_at <= self.until and not account.locked
|
|
|
|
|
|
def get_users(self):
|
|
@@ -41,6 +46,7 @@ class Bot(object):
|
|
|
|
|
|
def get_prev(users):
|
|
|
followers = self.client.fetch_previous(users)
|
|
|
+
|
|
|
filtered = [follower for follower in followers if self._should_get_msg(follower)]
|
|
|
users_to_msg.extend(filtered)
|
|
|
|
|
@@ -101,7 +107,7 @@ class Bot(object):
|
|
|
|
|
|
self.log.info('{} toots sent!'. format(len(users_to_msg)))
|
|
|
|
|
|
-def run():
|
|
|
+def create_bot():
|
|
|
env = Env()
|
|
|
env.read_env()
|
|
|
access_token = env('ACCESS_TOKEN')
|
|
@@ -123,6 +129,11 @@ def run():
|
|
|
account_id=account_id,
|
|
|
max_chars=max_chars)
|
|
|
|
|
|
+ return bot
|
|
|
+
|
|
|
+def run():
|
|
|
+ bot = create_bot()
|
|
|
+
|
|
|
while True:
|
|
|
bot.go()
|
|
|
time.sleep(2*60) # 2 mins
|