Skip to content

Commit

Permalink
clean player names in the hashtags
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucocustodio committed Jun 24, 2023
1 parent 6148609 commit 74d82cb
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
1 change: 1 addition & 0 deletions .env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ TWITTER_CONSUMER_KEY=TWITTER_CONSUMER_KEY
TWITTER_CONSUMER_SECRET=TWITTER_CONSUMER_SECRET
TWITTER_ACCESS_TOKEN=TWITTER_CONSUMER_SECRET
TWITTER_ACCESS_TOKEN_SECRET=TWITTER_ACCESS_TOKEN_SECRET
ENV=local
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# 🎾 Got Tennis Bot

A bot to get the best games of the day from [tennisexplorer.com](https://tennisexplorer.com) and tweet.
A [Twitter bot](https://twitter.com/GotTennisBot) to get the best games of the day from [tennisexplorer.com](https://tennisexplorer.com) and [tweet](https://twitter.com/GotTennisBot/status/1672490118588903425).

Best games: games from players that have rank position <= 100

Expand Down
11 changes: 7 additions & 4 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def get_match_data(row):
# head function is used just in case I want to limit when developing locally
# get games of the day when both players have ranking position <= relevant_rank
match_data = games\
.head(50)\
.head(1000)\
.parallel_apply(get_match_data, axis=1)\
.query('status != "complete"')\
.query(f"player1_ranking <= {relevant_rank} and player2_ranking <= {relevant_rank}")
Expand Down Expand Up @@ -83,10 +83,13 @@ def get_player_data(row):
print(f"failed to get player data for {row}")
pass

def hashify(name):
return name.replace(" ", "").replace("'", "").replace("-", "")

tour = row['tour'].upper()
tournament_hashtag = row['tournament'].replace(" ", "")
player1_hashtag = row['player1_name'].replace(" ", "")
player2_hashtag = row['player2_name'].replace(" ", "")
tournament_hashtag = hashify(row['tournament'])
player1_hashtag = hashify(row['player1_name'])
player2_hashtag = hashify(row['player2_name'])

row["tweet"] = f"""
{verbose_player1_name} (rank #{int(row['player1_ranking'])}) vs {verbose_player2_name} (rank #{int(row['player2_ranking'])})\n
Expand Down

0 comments on commit 74d82cb

Please sign in to comment.