-
-
Notifications
You must be signed in to change notification settings - Fork 8
Bots: Game Thread Bot Type
The Game Thread Bot can be configured to post discussion threads on Reddit, related to off days and games for a given MLB team.
Add a bot in redball and select bot type: game_threads
. Ensure a valid reddit authorization is selected.
The default settings will be applied upon creation, and the bot will be functional with the exception of two required settings which must be configured in order for the bot to run:
-
Reddit
>SUBREDDIT
-
MLB
>TEAM
Adjust the remaining settings to satisfy your needs.
-
TEMPLATE_PATH
- Path where custom templates are stored (defaults to the same path as the standard templates: /redball/bots/game_threads/templates/). You may want to use this if you are running redball in Docker and you want to mount a folder for your custom templates (e.g. /app/custom_templates). See Custom Templates section below for more information.
-
LOG_TO_FILE
- Write the bot's log to file -
FILE_LOG_LEVEL
- Log level for log files, if file logging is enabled -
LOG_TO_CONSOLE
- Write the bot's log to console -
CONSOLE_LOG_LEVEL
- Log level for console, if console logging is enabled -
PROPAGATE
- Propagate logs to the parent logger (redball.log). You probably want this set to False. -
LOG_RETENTION
- Log File Retention (Days)
-
API_CACHE_SECONDS
- Number of seconds to cache data from MLB Stats API -
GAME_DATE_OVERRIDE
- Leave blank in most cases. Use this to force the bot to treat a specific date as 'today', and then go back to current day. Date format: %Y-%m-%d, e.g.2019-10-25
. -
TEAM
- Select the team you want the bot to run for
-
FLAIR_MODE
- Method of adding flair to posts. Depends on subreddit configuration. Options are mod, submitter, and none/blank. -
INBOX_REPLIES
- Subscribe to inbox replies for submitted posts and comments -
STICKY
- Sticky submitted posts (requires mod rights in the subreddit) -
SUBREDDIT
- Subreddit where posts should be submitted
-
BOXSCORE_STYLE
- Boxscore layout for game day threads. Wide: traditional side-by-side layout. Stacked: Away box first, then Home box below. -
DATE_FORMAT
- Override the date format in the thread title (default:%A, %B %d
) -
ENABLED
- Enable posting of game day threads (aka tailgate or pregame threads) -
FLAIR
- Flair to add to game day thread post -
LIVE_DISCUSSION
- Submit post aslive discussions
instead of traditional comment threads on new Reddit (old Reddit will still show traditional comment threads) -
FOOTER
- Footer text to include at the bottom of the thread -
POST_TIME
- Time of day when game day thread should be posted. Include zero-padded hour and minute in 24 hour time, e.g. 08:00 or 14:30. -
SUGGESTED_SORT
- Suggested sort to set on the game day thread post -
SUPPRESS_MINUTES
- Game day thread will be skipped if game thread will be posted within this many minutes. Set to 0 to suppress game day thread only if it is already time to post game thread. Set to -1 to never suppress game day thread. -
THREAD_TEMPLATE
- Template for the thread body. See Custom Templates section below for more information. -
TITLE_TEMPLATE
- Template for the thread title. See Custom Templates section below for more information. -
TITLE_PREFIX
- Prefix at the beginning of the thread title -
UPDATE_INTERVAL
- Number of minutes between game day thread updates -
UPDATE_UNTIL
- Keep updating the thread until the selected threshold is reached-
Do not update
- Submit the thread and don't keep it updated -
Game thread is posted
- Keep the game day thread updated until the game thread is posted (for any game in case of doubleheader or split-squad) -
My team's games are final
- Keep the game day thread updated until all of my team's games are final -
All division games are final
- Keep the game day thread updated until all games involving teams in the same division as the configured team are final -
All MLB games are final
- Keep the game day thread updated until all games across the entire MLB are final
-
-
WEBHOOK_URL
- url to call when thread is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc.
-
BOXSCORE_STYLE
- Boxscore layout for game threads. Wide: traditional side-by-side layout. Stacked: Away box first, then Home box below. -
DATE_FORMAT
- Override the date format in the thread title (default:%a, %b %d @ %I:%M %p %Z
) -
DATE_FORMAT_DH
- Override the date format in the thread title for straight doubleheader game 2, which should not include a start time (default:%a, %b %d
) -
ENABLED
- Enable posting of game threads -
FLAIR
- Flair to add to game thread post -
LIVE_DISCUSSION
- Submit post aslive discussions
instead of traditional comment threads on new Reddit (old Reddit will still show traditional comment threads) -
LOCK_GAMEDAY_THREAD
- Lock game day thread when game thread is posted -
LINK_IN_GAMEDAY_THREAD
- Post a stickied comment in the game day thread, containing a link to the game thread, when the game thread is posted -
GAMEDAY_THREAD_MESSAGE
- Not included in the UI by default. Add this setting to override the default comment message posted in the game day thread ifLINK_IN_GAMEDAY_THREAD
isTrue
-
FOOTER
- Footer text to include at the bottom of the thread -
MINUTES_BEFORE
- How many minutes before the scheduled game start time to post the game thread -
MSG_BASEBALLBOT
- Send a message to u/BaseballBot with a link to the newly-posted game thread, which will be inserted in the sidebar of r/baseball. Do not enable when testing! -
POST_BY
- Time of day by which game thread should be posted, if the configured time comes before MINUTES_BEFORE setting. Include zero-padded hour and minute in 24 hour time, e.g. 08:00 or 14:30. -
SUGGESTED_SORT
- Suggested sort to set on the game thread post -
THREAD_TEMPLATE
- Template for the thread body. See Custom Templates section below for more information. -
TITLE_TEMPLATE
- Template for the thread title. See Custom Templates section below for more information. -
TITLE_PREFIX
- Prefix at the beginning of the thread title -
UPDATE_INTERVAL
- Number of seconds between game thread updates while the game is in live status -
UPDATE_INTERVAL_NOT_LIVE
- Number of minutes between game thread updates while the game is not live -
UPDATE_UNTIL
- Keep updating the thread until the selected threshold is reached-
Do not update
- Post the game thread and then do not keep it updated. You probably do not want this. -
My team's games are final
- Keep updating today's game threads until all of today's games are final. In case of regular game (not doubleheader or split-squad), the game thread will stop updating when the game is final. -
All division games are final
- Keep updating the game thread until all games are final that involve a team in the same division as the configured team. This is a good option to support the Division Scoreboard in the game thread when post game threads are not enabled. -
All MLB games are final
- Keep updating the game thread until all games are final across the entire MLB. This is a good option if you are using the League Scoreboard and post game threads are not enabled.
-
-
WEBHOOK_URL
- url to call when thread is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc.
-
BODY_TEMPLATE
- Template for the comment body. See Custom Templates section below for more information. -
ENABLED
- Enable posting of comments in game threads for notable plays -
MYTEAM_BATTING_FOOTER
- Footer text to include at the bottom of every comment when the configured team is batting, even if there is an event-specific footer defined -
MYTEAM_BATTING_HEADER
- Header text to include at the top of every comment when the configured team is batting, even if there is an event-specific header defined -
MYTEAM_PITCHING_FOOTER
- Footer text to include at the bottom of every comment when the configured team is pitching, even if there is an event-specific footer defined -
MYTEAM_PITCHING_HEADER
- Header text to include at the top of every comment when the configured team is pitching, even if there is an event-specific header defined -
MYTEAM_BATTING_EVENTS
- Events that will trigger comments while configured team is batting. See Game Thread Comments section below for more information. -
MYTEAM_PITCHING_EVENTS
- Events that will trigger comments while configured team is pitching. See Game Thread Comments section below for more information. -
WEBHOOK_URL
- url to call when comment is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc. -
MYTEAM_<BATTING|PITCHING>_<HEADER|FOOTER>_<EVENT_CODE_ALLCAPS>
- custom header/footer for specific events when configured team is either batting or pitching. See Game Thread Comments section below for more information.
-
BOXSCORE_STYLE
- Boxscore layout for post game threads. Wide: traditional side-by-side layout. Stacked: Away box first, then Home box below. -
DATE_FORMAT
- Override the date format in the thread title (default:%a, %b %d @ %I:%M %p %Z
) -
DATE_FORMAT_DH
- Override the date format in the thread title for straight doubleheader game 2, which should not include a start time (default:%a, %b %d
) -
ENABLED
- Enable posting of post game threads -
FLAIR
- Flair to add to post game thread post -
LIVE_DISCUSSION
- Submit post aslive discussions
instead of traditional comment threads on new Reddit (old Reddit will still show traditional comment threads) -
LOCK_GAME_THREAD
- Lock game thread when post game thread is posted -
LINK_IN_GAME_THREAD
- Post a stickied comment in the game thread, containing a link to the post game thread, when the post game thread is posted -
GAME_THREAD_MESSAGE
- Not included in the UI by default. Add this setting to override the default comment message posted in the game thread ifLINK_IN_GAME_THREAD
isTrue
-
FOOTER
- Footer text to include at the bottom of the thread -
SUGGESTED_SORT
- Suggested sort to set on the post game thread post -
THREAD_TEMPLATE
- Template for the thread body. See Custom Templates section below for more information. -
TITLE_PREFIX
- Prefix at the beginning of the thread title - applies in all cases (even when another status-specific prefix applies) -
TITLE_PREFIX_EXCEPTION
- Prefix at the beginning of the thread title when the game ends in an exception status--postponed, canceled, suspended, etc. -
TITLE_PREFIX_HOME_WIN
- Prefix at the beginning of the thread title when the configured team wins at home -
TITLE_PREFIX_HOME_LOSS
- Prefix at the beginning of the thread title when the configured team loses at home -
TITLE_PREFIX_ROAD_WIN
- Prefix at the beginning of the thread title when the configured team wins on the road -
TITLE_PREFIX_ROAD_LOSS
- Prefix at the beginning of the thread title when the configured team loses on the road -
TITLE_TEMPLATE
- Template for the thread title. See Custom Templates section below for more information. -
UPDATE_INTERVAL
- Number of minutes between post game thread updates -
UPDATE_UNTIL
- Keep updating the thread until the selected threshold is reached-
Do not update
- Submit the post game thread and then do not keep it updated -
An hour after thread is posted
- Keep updating the post game thread for an hour after it is originally submitted. This will allow additional highlights to be added to the post, and will keep the division/league scoreboard updated in case other games are still in progress (but those games could still be in progress when the hour ends). -
All division games are final
- Keep updating the post game thread until all games are final that involve a team in the same division as the configured team. This is a good option to support the Division Scoreboard in the post game thread. -
All MLB games are final
- Keep updating the post game thread until all games are final across the entire MLB. This is a good option if you are using the League Scoreboard in the post game thread.
-
-
WEBHOOK_URL
- url to call when thread is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc.
-
DATE_FORMAT
- Override the date format in the thread title (default:%A, %B %d
) -
ENABLED
- Enable posting of off day threads -
FLAIR
- Flair to add to off day thread post -
LIVE_DISCUSSION
- Submit post aslive discussions
instead of traditional comment threads on new Reddit (old Reddit will still show traditional comment threads) -
FOOTER
- Footer text to include at the bottom of the thread -
POST_TIME
- Time of day when off day thread should be posted. Include zero-padded hour and minute in 24 hour time, e.g. 08:00 or 14:30. -
SUGGESTED_SORT
- Suggested sort to set on the off day thread post -
SUPPRESS_OFFSEASON
- Suppress off day threads during the offseason (including postseason if eliminated) -
THREAD_TEMPLATE
- Template for the thread body. See Custom Templates section below for more information. -
TITLE_TEMPLATE
- Template for the thread title. See Custom Templates section below for more information. -
TITLE_PREFIX
- Prefix at the beginning of the thread title -
UPDATE_INTERVAL
- Number of minutes between off day thread updates -
UPDATE_UNTIL
- Keep updating the thread until the selected threshold is reached-
Do not update
- Submit the thread and don't keep it updated -
All division games are final
- Keep the off day thread updated until all games involving teams in the same division as the configured team are final -
All MLB games are final
- Keep the off day thread updated until all games across the entire MLB are final
-
-
WEBHOOK_URL
- url to call when thread is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc.
-
DATE_FORMAT
- Override the date format in the thread title (default:%A, %B %d
) -
ENABLED
- Enable posting of weekly threads -
FLAIR
- Flair to add to weekly thread post -
LIVE_DISCUSSION
- Submit post aslive discussions
instead of traditional comment threads on new Reddit (old Reddit will still show traditional comment threads) -
FOOTER
- Footer text to include at the bottom of the thread -
POST_TIME
- Time of day when weekly thread should be posted. Include zero-padded hour and minute in 24 hour time, e.g. 08:00 or 14:30. Thread will be posted on Monday each week, or the first day of the offseason (postseason if eliminated) -
SUGGESTED_SORT
- Suggested sort to set on the weekly thread post -
OFFSEASON_ONLY
- Post weekly threads only during the offseason (including postseason if eliminated) -
THREAD_TEMPLATE
- Template for the thread body. See Custom Templates section below for more information. -
TITLE_TEMPLATE
- Template for the thread title. See Custom Templates section below for more information. -
TITLE_PREFIX
- Prefix at the beginning of the thread title -
WEBHOOK_URL
- url to call when thread is submitted -
WEBHOOK_TEMPLATE
- template to parse for the body of the call toWEBHOOK_URL
-
WEBHOOK[1-9]_URL
- additional urls to call when thread is submitted, e.g.WEBHOOK1_URL
,WEBHOOK2_URL
, etc. -
WEBHOOK[1-9]_TEMPLATE
- templates to parse for the body of the call toWEBHOOK[N]_URL
, e.g.WEBHOOK1_TEMPLATE
,WEBHOOK2_TEMPLATE
, etc.
Note: Generate your API key here.
-
ERROR_API_KEY
- API Key for sending error notifications to Prowl -
ERROR_PRIORITY
- Priority when sending error notifications to Prowl (leave blank to disable) -
THREAD_POSTED_API_KEY
- API Key for sending thread posted notifications to Prowl -
THREAD_POSTED_PRIORITY
- Priority when sending thread posted notifications to Prowl (leave blank to disable)
Note: Please follow the instructions here to generate the required values.
-
TWEET_THREAD_POSTED
- Tweet when threads are posted -
CONSUMER_KEY
- Twitter Consumer Key -
CONSUMER_SECRET
- Twitter Consumer Secret -
ACCESS_TOKEN
- Twitter Access Token -
ACCESS_SECRET
- Twitter Access Secret
The thread templates are in mako format, using a combination of Python and Markdown.
Don't modify the standard template files because your changes will be lost when updating redball. Make a copy of the template file(s) you want to modify instead, and put the filename in the THREAD_TEMPLATE
or TITLE_TEMPLATE
settings for the applicable threads.
By default, the path for custom templates is the same as the standard templates: /redball/bots/game_threads/templates/ (relative to code root; in Docker this would be /app/redball/bots/game_threads/templates/). This path can be configured in the Bot
> TEMPLATE_PATH
setting.
You will want to configure a different path if you are running redball in Docker, so you can mount a folder that contains your custom template files, for example: /app/custom_templates.
For help customizing thread/title templates, submit an issue, ask on discord or submit a post in r/redball.
If the COMMENTS
:ENABLED
setting is True
, the bot will submit a comment to the game thread when the events listed in the MYTEAM_BATTING_EVENTS
and MYTEAM_PITCHING_EVENTS
settings occur (when the configured team is either batting or pitching, respectively).
Separate multiple events with commas, for example: scoring_play, pitching_substitution, triple_play
.
Event codes can be found at https://statsapi.mlb.com/api/v1/eventTypes. Also available: 'scoring_play'.
Custom header and footer text can be configured per event code, separately for when the configured team is batting vs. pitching. Add a custom string setting to the Comments
section in the format MYTEAM_<BATTING|PITCHING>_<HEADER|FOOTER>_<EVENT_CODE_ALLCAPS>
. For example: MYTEAM_BATTING_HEADER_HOME_RUN
, MYTEAM_PITCHING_FOOTER_STRIKEOUT
. Be sure to include #
(or ##
or ###
) in the value if you want the text to be a header in the comment, because the code will not include it automatically.
As with the delayed start of the 2020 season, the game thread bot (v0.0.6+) will treat any day when all MLB games are postponed as an off day. The decision of off day vs. game day is made at the latest of 1. Midnight, 2. when the last gameday/game/post/off thread finishes updating for the day, or 3. when the bot is started. Therefore, barring some unexpected scenario where a bot is (re)started late in the day on a day when there is only one game, and that game involves the configured team, and it happens to be postponed, the assumption should hold that if all MLB games for a given day are postponed, the league is suspended (at least for that day).
You can find the source code for the game thread bot in bots\game_threads_init_.py. Note that this is the latest official version of the code, and individual bot-runners may be running an earlier or custom version.
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.