From 74d82cb0dd77037cf6b2c9a7a25230e94975ef27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Glauco=20Cust=C3=B3dio?= Date: Fri, 16 Jun 2023 10:47:17 +0100 Subject: [PATCH] clean player names in the hashtags --- .env.sample | 1 + README.md | 2 +- bot.py | 11 +++++++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.env.sample b/.env.sample index 0a921e2..e7a2c7c 100644 --- a/.env.sample +++ b/.env.sample @@ -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 diff --git a/README.md b/README.md index 06e336c..4200273 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/bot.py b/bot.py index 43c24a2..89d35e3 100644 --- a/bot.py +++ b/bot.py @@ -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}") @@ -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