def run(tags): log.info("Follow mode activated", tags=tags) if tags is None or len(tags) < 1: raise ValueError("You must specify at least one tag") log.debug("initializing...") steem = Steem(keys=[cred.key]) account = Account(cred.id, steem) chain = Blockchain(steem) log.debug("ready", steem=steem, account=account, blockchain=chain) log.info("Gathering our following list...") following = account.get_following() pending = [] log.info("Following list retrieved", count=len(following)) log.info("Watching for new posts...") while True: stream = map(Post, chain.stream(filter_by=['comment'])) try: for post in stream: count = len(pending) if count > 0: copy = list(pending) for i in range(count): if have_bandwidth(steem, account): user = copy[i] log.info("following user", user=user) steem.follow(user, account=cred.id) del pending[0] else: log.warn("Waiting for more bandwidth before following another user") break if post.is_main_post(): log.debug("found a top-level post", author=post.author, tags=post.tags) if post.author != cred.id: for tag in tags: if tag in post.tags: if post.author not in following: pending.append(post.author) following.append(post.author) break except PostDoesNotExist as e: log.debug("Post has vanished", exception=e) except RPCError as e: log.error("RPC problem while streaming posts", exception=e)
for i in al_: if '\n' in i: i = i.replace('\n', '') if i not in following: following.append(i) ### counter = 0 count = 1 print(len(active)) while len(active) > 0: for i in active: if i not in following: try: s.follow(i) active.remove(i) fol.append(i) counter += 1 except Exception: pass print('FAILED') if counter == 15: print('ROUND', count) print('FOLLOWED 15') print(len(active), 'TO GO') print(len(fol), 'TOTAL FOLLOWED') print('__________________________') counter = 0 count += 1