Skip to content

Commit

Permalink
Ability to tune #followers
Browse files Browse the repository at this point in the history
  • Loading branch information
schedutron committed Mar 5, 2019
1 parent ec876f4 commit 42d038c
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1 +1 @@
worker: python3 -m chirps.main --rate=300 --fav --retweet --follow --scrape scrape_thenewstack get_tech_news
worker: python3 -m chirps.main --rate=300 --fav --retweet --follow --follow_limit=6000 --scrape scrape_thenewstack get_tech_news
4 changes: 3 additions & 1 deletion chirps/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@
action="store_true")
parser.add_argument("--follow", help="flag to enable following people",
action="store_true")
parser.add_argument("--follow_limit", help="maximum number of people to follow",
default=4000, type=int)
parser.add_argument("--scrape", help="flag to specify content scraping",
default="", nargs="*")
args = parser.parse_args()
Expand Down Expand Up @@ -63,7 +65,7 @@ def main():
account_manager = managers.AccountThread(ACCOUNT_HANDLER, UPLOAD_HANDLER,
url, args.rate, args.fav,
args.retweet, args.follow,
args.scrape)
args.follow_limit, args.scrape)
admin = managers.StreamThread(
"Admin", ADMIN_HANDLER, ACCESS_SECRET, url, functions.admin_action)
streamer.start()
Expand Down
5 changes: 3 additions & 2 deletions chirps/managers.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def run(self):
class AccountThread(threading.Thread):
"""Account thread manages favoriting, retweeting and following people who
tweet interesting stuff."""
def __init__(self, handler, upload_handler, url, sleep_time, fav, retweet, follow, scrape):
def __init__(self, handler, upload_handler, url, sleep_time, fav, retweet, follow, follow_limit, scrape):
threading.Thread.__init__(self)
self.handler = handler
self.upload_handler = upload_handler
Expand All @@ -98,6 +98,7 @@ def __init__(self, handler, upload_handler, url, sleep_time, fav, retweet, follo
self.fav = fav
self.retweet = retweet
self.follow = follow
self.follow_limit = follow_limit
self.scrape = scrape
print('sleep_time: %s, fav: %s, retweet: %s, follow: %s, scrape: %s' %
(self.sleep_time, self.fav, self.retweet, self.follow, self.scrape)
Expand All @@ -120,7 +121,7 @@ def run(self):

if self.follow:
friends_ids = self.handler.friends.ids(screen_name=screen_name)["ids"]
if len(friends_ids) > 4000:
if len(friends_ids) > follow_limit:

# To unfollow old follows because Twitter doesn't allow a large
# following / followers ratio for people with less followers.
Expand Down

0 comments on commit 42d038c

Please sign in to comment.