Skip to content

Bots: MLB Data Bot Type

toddrob edited this page Nov 10, 2019 · 1 revision

The MLB Data Bot responds to comments in the configured subreddit(s) with requested MLB data.

Setup/Configuration

Add a bot in redball and select bot type: mlb_data. Ensure a valid reddit authorization is selected.

The only required bot setting is SUBREDDIT in the Reddit category, which is the subreddit for the bot to monitor. Separate multiple subreddits with + (e.g. MySubreddit+MyOtherSub).

The other supported bot settings are in the Bot category:

  • DEL_THRESHOLD - Delete comments with score at or below X, default: -2.
  • HISTORICAL_DAYS - Process comments X days old, default: 1.
  • PAUSE_AFTER - Pause comment stream to check for downvoted comments after X cycles with no new comments, default: 3. Decrease for more active subreddits, increase for less active subreddits.
  • REPLY_FOOTER - Text to include at the bottom of comment responses posted by the bot, default: ^^I ^^am ^^a ^^bot. ^^Not ^^affiliated ^^with ^^MLB. ^^Downvoted ^^replies ^^will ^^be ^^deleted. ^^[[source/doc](https://github.com/toddrob99/redball/wiki/MLB-Data-Bot)] ^^[[feedback](https://reddit.com/r/redball/)].

Source Code

You can find the source code in bots\mlb_data.py. Note that this is the latest official version of the code, and individual bot-runners may be running an earlier or custom version.

Use

Invoke the bot in a monitored subreddit by including the bot's reddit username in a comment.

Include a command, subject, and qualifier as needed, and the bot will reply with the requested data.

Downvoted replies will be deleted automatically.

Commands

help

Subject: None

Qualifier: None

Reply: Information about using the bot, including a list of commands.

Example: botname help

careerstats

Subject: Player name, enclosed in {} anywhere in your comment. Can be part of first name, last name, or full name in format 'Last, First'. Include enough for the bot to uniquely identify a single player, or you might not get the result you expect. For example, Aaron Nola's last name is part of Nolan Arenado's first name, so in order to get stats for Aaron Nola, try {nola,} (enough of 'last, first' format to be unique).

Qualifier: Type of stats requested, anywhere in your comment. Available values: hitting/batting, pitching, and fielding. Include multiple types if you wish, or leave out the qualifier to return all available.

Reply: The given player's career stats of the type(s) requested. If the player fielded in multiple positions, there will be separate sections in the reply for each position.

Example: botname careerstats {nola,} pitching

seasonstats

Subject: Player name, enclosed in {} anywhere in your comment. Can be part of first name, last name, or full name in format 'Last, First'. Include enough for the bot to uniquely identify a single player, or you might not get the result you expect. For example, Aaron Nola's last name is part of Nolan Arenado's first name, so in order to get stats for Aaron Nola, try {nola,} (enough of 'last, first' format to be unique).

Qualifier: Type of stats requested, anywhere in your comment. Available values: hitting/batting, pitching, and fielding. Include multiple types if you wish, or leave out the qualifier to return all available.

Reply: The given player's career stats of the type(s) requested. If the player fielded in multiple positions, there will be separate sections in the reply for each position.

Example: botname seasonstats {hoskins} batting

score

Subject: Team or division, enclosed within {} anyhwere in your comment. Can be part of the team's name, location, or team code. Include enough characters to uniquely identify a team. For example, 'lad' will return PhiLADelphia and not LA Dodgers as you might expect. To return scores for any games for a given division, include the abbreviation (nle, alw, etc.).

Qualifier: None

Reply: A summary of requested games, including teams, scores if game is in progress or final, inning if game is in progress, and status.

Example: botname score {nle} or `botname score {phillies}

standings

Subject: Division or league, enclosed within {} anywhere in your comment. Leave out for all divisions in both leagues. Include abbreviation for the league/division you want, for example {nl} or {alw}.

Qualifier: Include wildcard or wc in your comment if you want wildcard standings to be included in the reply.

Reply: Division standings for the requested division/league(s), including wildcard standings if qualifier is present.

Example: botname standings {nle} or botname standings {al} wildcard

nextgame

Subject: Team name, enclosed in {} anywhere in your comment. Can be part of the team's name, location, or team code. Include enough characters to uniquely identify a team. For example, 'lad' will return PhiLADelphia and not LA Dodgers as you might expect. To return scores for any games for a given division, include the abbreviation (nle, alw, etc.).

Qualifier: None

Reply: Summary information about the given team's next game, including team names, scores if game is in progress or final, inning if game is in progress, and status.

Example: botname nextgame {oakland}

Note: The MLB API seems to get confused and return an unexpected game when requesting the next or previous game. This is how the API is returning the data, and there is nothing I can easily do to make this work better.

lastgame

Subject: Team name, enclosed in {} anywhere in your comment. Can be part of the team's name, location, or team code. Include enough characters to uniquely identify a team. For example, 'lad' will return PhiLADelphia and not LA Dodgers as you might expect. To return scores for any games for a given division, include the abbreviation (nle, alw, etc.).

Qualifier: None

Reply: Summary information about the given team's last game, including team names, scores if game is in progress or final, inning if game is in progress, and status.

Example: botname lastgame {cubs}

Note: The MLB API seems to get confused and return an unexpected game when requesting the next or previous game. This is how the API is returning the data, and there is nothing I can easily do to make this work better.

winprob

Subject: Team name, enclosed in {} anywhere in your comment. Can be part of the team's name, location, or team code. Include enough characters to uniquely identify a team. For example, 'lad' will return PhiLADelphia and not LA Dodgers as you might expect. To return scores for any games for a given division, include the abbreviation (nle, alw, etc.).

Qualifier: None

Reply: Game summary information, as well as current win probabilities for both teams. Works best while the team has a game in progress.

Example: botname winprob {phi}

Copyright Notice

This bot and its author are not affiliated with MLB or any MLB team. This project uses the MLB-StatsAPI and PRAW packages to interface with the MLB and Reddit APIs. Use of MLB data is subject to the notice posted at http://gdx.mlb.com/components/copyright.txt.