Skip to content

Commit

Permalink
Support multiple tags. (Fixes #6)
Browse files Browse the repository at this point in the history
  • Loading branch information
emre committed Apr 4, 2018
1 parent 105e518 commit 2323d99
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tagbot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class TagBot:
def __init__(self, config, steemd_instance):
self.config = config
self.steemd_instance = steemd_instance
self.target_tags = config.get("TAGS") or [config.get("TAG"), ]

def check_vp(self):
current_vp = get_current_vp(
Expand Down Expand Up @@ -58,12 +59,13 @@ def reputation_is_enough(self, author_rep):
return reputation(author_rep) > self.config["MINIMUM_AUTHOR_REP"]

def start_voting_round(self):
# Fetch last 100 posts on the selected tag
query = {"limit": 100, "tag": self.config["TAG"]}
posts = list(self.steemd_instance.get_discussions_by_created(query))
posts = []
for tag in self.target_tags:
logger.info("Fetching #%s tag", tag)
query = {"limit": 100, "tag": tag}
posts += list(self.steemd_instance.get_discussions_by_created(query))
logger.info("%s posts found.", len(posts))

# Voted accounts in the last 24h
already_voted = self.last_voted_accounts()

blacklist = self.config.get("BLACKLIST", [])
Expand Down Expand Up @@ -104,6 +106,8 @@ def start_voting_round(self):
random.shuffle(filtered_posts)

for post in posts[0:self.config["VOTE_COUNT"]]:
if self.config.get("DEBUG"):
break
self.upvote(
Post(post, steemd_instance=self.steemd_instance),
self.config["VOTE_WEIGHT"]
Expand Down

0 comments on commit 2323d99

Please sign in to comment.