Skip to content
This repository has been archived by the owner on May 21, 2023. It is now read-only.

Commit

Permalink
Add team emojis, closes #15
Browse files Browse the repository at this point in the history
  • Loading branch information
greg-finley committed Sep 21, 2022
1 parent 8c75af1 commit 9f15a30
Showing 1 changed file with 43 additions and 2 deletions.
45 changes: 43 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,39 @@
DRY_RUN = os.environ.get("DRY_RUN", "false").lower() == "true"
LOCAL = os.environ.get("LOCAL", "false").lower() == "true"

TEAM_ID_TO_HASHTAG = {
108: "#GoHalos",
109: "#Dbacks",
110: "#Birdland",
111: "#DirtyWater",
112: "#ItsDifferentHere",
113: "#ATOBTTR",
114: "#ForTheLand",
115: "#Rockies",
116: "#DetroitRoots",
117: "#LevelUp",
118: "#TogetherRoyal",
119: "#AlwaysLA",
120: "#NATITUDE",
121: "#LGM",
133: "#DrumTogether",
134: "#LetsGoBucs",
135: "#TimeToShine",
136: "#SeaUsRise",
137: "#SFGameUp",
138: "#STLCards",
139: "#RaysUp",
140: "#StraightUpTX",
141: "#NextLevel",
142: "#MNTwins",
143: "#RingTheBell",
144: "#ForTheA",
145: "#ChangeTheGame",
146: "#MakeItMiami",
147: "#RepBX",
158: "#ThisIsMyCrew",
}


@dataclass
class State:
Expand All @@ -43,6 +76,7 @@ class Play:
endTime: str
batter_name: str
batter_id: int
batter_team_id: int


@dataclass
Expand All @@ -58,6 +92,8 @@ class ImageInput:
class Game:
game_id: int
is_complete: bool
home_team_id: int
away_team_id: int


def main(event, context):
Expand Down Expand Up @@ -128,6 +164,8 @@ def get_current_games(self, completed_games: list[int]) -> list[Game]:
Game(
game_id=game_id,
is_complete=abstract_game_state == "Final",
home_team_id=g["teams"]["home"]["team"]["id"],
away_team_id=g["teams"]["away"]["team"]["id"],
)
)
return games
Expand All @@ -151,6 +189,9 @@ def get_unprocessed_plays(self, games: list[Game], state: State) -> list[Play]:
endTime=p["about"]["endTime"],
batter_name=p["matchup"]["batter"]["fullName"],
batter_id=p["matchup"]["batter"]["id"],
batter_team_id=g.away_team_id
if p["about"]["isTopInning"]
else g.home_team_id,
)
plays.append(play)

Expand Down Expand Up @@ -182,9 +223,9 @@ def tweet(self, play: Play, state: State, matching_letters: list[str]) -> None:
hit_type = play.event
alert = self._alert(matching_letters)

tweet_text = f"""{alert}{play.batter_name} just hit a {hit_type.lower()}!
tweet_text = f"""{alert}{play.batter_name} just hit a {hit_type.lower()}! {TEAM_ID_TO_HASHTAG[play.batter_team_id]}
His name has the letter{'' if len(matching_letters) == 1 else 's'} {oxford_comma(matching_letters)}, so the next letter in the MLB Alphabet Game is now {state.current_letter}.
His name has the letter{'' if len(matching_letters) == 1 else 's'} {oxford_comma(matching_letters)}. The next letter in the MLB Alphabet Game is now {state.current_letter}.
We have cycled through the alphabet {state.times_cycled} times since this bot was created on 9/17."""
print(tweet_text)
Expand Down

0 comments on commit 9f15a30

Please sign in to comment.