Latest Version: v8.3.1-beta
Do you like the app? Star the repository here on GitHub and please consider helping support its development:
Cryptocurrency | Donation Link (Trust Wallet) | Wallet Address |
---|---|---|
Bitcoin - BTC | bc1qataspvklhewtswm357m0677q4raag5new2xt3e |
|
Ethereum - ETH | 0x5eAa522e66a90577D49e9E72f253EC952CDB4059 |
|
Nano Currency - NANO | nano_3ug3o6yy983jsqdsc773izhr3jfz4dq8bz7yfhhzkkeq7s8ern1ws7dng4pq |
- About
- Dependencies
- Setup
- Running the Report Application
- Configuration
- Usage
- Additional Integrations
- Troubleshooting
The Fantasy Football Metrics Weekly Report application automatically generates a report in the form of a PDF file that contains a host of metrics and rankings for teams in a given fantasy football league.
Currently supported fantasy football platforms:
-
Yahoo
-
Fleaflicker
-
Sleeper
-
ESPN
You can see an example of what a report looks like here!
The application has only been tested in macOS, but should be cross-platform compatible. The app requires Python 3.6 or later (Python 2 is no longer supported). To check if you have Python 3.6 installed, open up a window in Terminal (macOS), Command Prompt (Windows), or a command line shell of your choice, and run python --version
. If the return is Python 3.6.x
, you are good to go. If the return is Python 2.x.x
, you will need to install Python 3.6. Check out the instructions here for how to install Python 3.6 on your system.
Project dependencies can be viewed in the requirements.txt
file.
The Fantasy Football Metrics Weekly Report requires several different sets of setup steps, depending on how you wish to run it. To get the application running locally, you will first need to go through the following steps.
* General setup excludes Google Drive and Slack integrations. See Additional Integrations for details on including those add-ons.
There is a pre-made setup bash script in the top level of this repository called setup.sh
. In lieu of doing the manual setup steps, you can simply do the following:
-
Note: This script has not been extensively tested. It was added in order to simplify the required setup steps, but please still do your best to verify that things worked properly after running it before moving on to running the application.
-
Download the script by right-clicking https://raw.githubusercontent.com/uberfastman/fantasy-football-metrics-weekly-report/develop/setup.sh and selecting "Download Linked File". A file download should start to your local downloads folder (default is
~/Downloads/
on macOS). -
Open a command line prompt
- macOS: type
Cmd + Space
(⌘ + Space
) to bring up Spotlight, and search for "Terminal" and hit enter).
- macOS: type
-
Navigate to wherever you wish to have the Fantasy Football Metrics Weekly Report application set up:
Example (use whatever directory in which you wish to store the app):
cd ~/projects
-
Move the the
setup.sh
script to the above location:Example (move the file from your downloads folder):
mv ~/Downloads/setup.sh .
-
Run
./setup.sh
- If you get an error when running
./setup.sh
, the script might not be executable. You can runchmod +x setup.sh
to make it executable. You may need to execute thechmod
command as an administrator, depending on your system permissions, in which case you can runsudo chmod +x setup.sh
and then enter your password.
- If you get an error when running
-
You can now skip ahead to Running the Report Application.
-
Make sure your operating system (OS) has Python 3 installed. See the above section on dependencies for instructions.
-
After you've finished installing Python 3, check that it has been successfully installed by running
python3 --version
(orpy -0p
(orpy -3
to see if you can launch Python 3 ifpy -0p
fails) if using the Python launcher for Windows in Windows to list installed Python version with their paths) in the command line again, and confirming that it outputsPython 3.x.x
. If it does not, double check that you followed all Python 3 installation steps correctly. -
Open a command line prompt
- macOS: type
Cmd + Space
(⌘ + Space
) to bring up Spotlight, and search for "Terminal" and hit enter). - Windows: type
Windows + R
to open the "Run" box, then typecmd
and then click "OK" to open a regular Command Prompt (or typecmd
and then pressCtrl + Shift + Enter
to open an administrator Command Prompt) - Linux: type
Ctrl+Alt+T
(in Ubuntu).
- macOS: type
-
Install
git
(if you do not already have it installed). You can see instructions for installation on your OS here. If you are comfortable using the command line, feel free to just installgit
for the command line. However, if using the command line is not something you have much experience with and would prefer to do less in a command line shell, you should install Git for Desktop. -
Clone this project to whichever directory you wish:
-
If you already have an account on GitHub, then I recommend using SSH to connect with GitHub.
-
If using SSH (as described in the link above), run:
git clone git@github.com:uberfastman/fantasy-football-metrics-weekly-report.git
- If not using SSH, then use HTTPS by running:
git clone https://github.com/uberfastman/fantasy-football-metrics-weekly-report.git
-
-
Run
cd fantasy-football-metrics-weekly-report
to enter the project directory. -
Set up a virtual environment:
-
macOS/Linux:
-
Run
pip3 install virtualenv virtualenvwrapper
(if not already installed). -
Run
touch ~/.bashrc
. -
Run
echo 'export WORKON_HOME=$HOME/.virtualenvs' >> ~/.bashrc echo 'source /usr/local/bin/virtualenvwrapper.sh' >> ~/.bashrc
-
Run
source ~/.bashrc
-
Run
which python3
. This should output something like/usr/local/bin/python3
. Copy that path for the next step.
-
-
Windows:
-
Run
pip3 install virtualenv virtualenvwrapper-win
-
Details for using
virtualenvwrapper-win
can be found here.
-
-
-
Run
mkvirtualenv -p /usr/local/bin/python3 fantasy-football-metrics-weekly-report
. -
When the previous command is finished running, your command line prompt should now look something like this:
(fantasy-football-metrics-weekly-report) [username@Computer 02:52:01 PM] ~/fantasy-football-metrics-weekly-report $
Congratulations, you have successfully created a Python 3 virtual environment for the project to run in!
-
Finally, run
pip install -r requirements.txt
-
Log in to a Yahoo account with access to whatever fantasy football leagues from which you wish to retrieve data.
-
Retrieve your Yahoo Fantasy football league id, which you can find by going to https://football.fantasysports.yahoo.com, clicking on your league, and looking here:
-
Change the
league_id
value inconfig.ini
to the above located league id. -
Go to https://developer.yahoo.com/apps/create/ and create an app (you must be logged into your Yahoo account as stated above). For the app, select the following options:
-
Application Name
(Required):yahoo fantasy sports metrics
(you can name your app whatever you want, but this is just an example). -
Application Type
(Required): select theInstalled Application
radio button. -
Description
(Optional): you may write a description of what the app does. -
Home Page URL
(Optional): if you have a web address related to your app you may add it here. -
Redirect URI(s)
(Required): this field must contain a valid redirect address, so you can uselocalhost:8080
-
API Permissions
(Required): check theFantasy Sports
checkbox. You can leave theRead
option selected (appears in an accordion expansion underneath theFantasy Sports
checkbox once you select it). -
Click the
Create App
button. -
Once the app is created, it should redirect you to a page for your app, which will show both a
Client ID
and aClient Secret
. -
Copy the file
EXAMPLE-private.json
(located in theauth/yahoo/
directory), and rename the file copyprivate.json
, then copy and paste theClient ID
andClient Secret
values from your above created Yahoo app to their respective fields (make sure the strings are wrapped regular quotes (""
), NOT formatted quotes (“”
)). The path to this file will be needed to point the YFPY API wrapper responsible for data retrieval to your credentials. -
The first time you run the app, it will initialize the OAuth connection between the report generator and your Yahoo account.
-
-
NOTE: *If your Yahoo league uses FAAB (Free Agent Acquisition Budget) for player waivers, you must set the
initial_faab_budget
value in theconfig.ini
file to reflect your league's starting budget, since this information does not seem to be available in the Yahoo API. -
You are now ready to generate a report!
Fleaflicker recently implemented a public API, but at the present time it is undocumented and subject to unexpected and sudden changes. Please note, some of the data required to provide certain information to the report is not currently available in the Sleeper API, so for the time being web-scraping is used to supplement the data gathered from the Fleaflicker API.
-
Retrieve your Fleaflicker league ID. You can find it by looking at the URL of your league in your browser:
-
Change the
league_id
value inconfig.ini
to the above located league id. -
Make sure that you have accurately set the
season
configuration value in theconfig.ini
file to reflect the desired year/season for which you are running the report application. This will ensure that the location of locally saved data is correct and API requests are properly formed. -
You can also specify the
year
from the command line by running the report with the-y <chosen_year>
flag. -
Fleaflicker does not require any authentication to access their API at this time, so no additional steps are necessary.
-
You are now ready to generate a report!
Sleeper has a public API, the documentation for which is available here. The Fantasy Football Metrics Weekly Report application uses this API to retrieve the necessary data to generate reports. Please note, some of the data required to provide certain information to the report is not currently available in the Sleeper API, so a few small things are excluded in the report until such a time as the data becomes available. That being said, the missing data does not fundamentally limit the capability of the app to generate a complete report.
-
Retrieve your Sleeper league ID. You can find it by looking at the URL of your league in your browser:
-
Change the
league_id
value inconfig.ini
to the above located league id. -
Make sure that you have accurately set the
current_week
configuration value in theconfig.ini
file to reflect the current/ongoing NFL week at the time of running the report. This is required for the Fantasy Football Metrics Weekly Report app to run correctly! -
Sleeper does not require any authentication to access their API at this time, so no additional steps are necessary.
-
You are now ready to generate a report!
ESPN has a public API, but it was just changed from v2 to v3, which introduced some variance to its functionality. At the present time it is also undocumented and subject to unexpected and sudden changes. Please note, some of the data required to provide certain information to the report is not currently available in the ESPN API, so a few small things are excluded in the report until such a time as the data becomes available. That being said, the missing data does not fundamentally limit the capability of the app to generate a complete report.
-
Retrieve your ESPN league ID. You can find it by looking at the URL of your league in your browser:
-
Change the
league_id
value inconfig.ini
to the above located league id. -
Make sure that you have accurately set the
season
configuration value in theconfig.ini
file to reflect the desired year/season for which you are running the report application. This will ensure that the location of locally saved data is correct and API requests are properly formed. -
You can also specify the
year
from the command line by running the report with the-y <chosen_year>
flag. -
Public ESPN leagues do not require any authentication to access their API at this time, so no additional steps are necessary for those leagues. However, certain data will not be available if you are not authenticated, so it is advised for you to still follow the below authentication steps anyway. For private leagues, you must complete the following authentication steps:
-
Steven Morse has done a great deal of fantastic work to help teach people how to use the ESPN fantasy API, and has a useful blog post here detailing how to get your own session cookies. As stated in the aforementioned blog, you can get the cookies by doing the following:
-
"A lot of the ESPN Fantasy tools are behind a login-wall. Since accounts are free, this is not a huge deal, but becomes slightly annoying for GET requests because now we somehow need to “login” through the request. One way to do this is to send session cookies along with the request. Again this can take us into a gray area, but to my knowledge there is nothing prohibited about using your own cookies for personal use within your own league.
Specifically, our GET request from the previous post is modified to look like, for example:
r = requests.get('http://games.espn.com/ffl/api/v2/scoreboard', params={'leagueId': 123456, 'seasonId': 2017, 'matchupPeriodId': 1}, cookies={'swid': '{SWID-COOKIE-HERE}', 'espn_s2': 'LONG_ESPN_S2_COOKIE_HERE'})
This should return the info you want even for a private league. I saw that the SWID and the ESPN_S2 cookies were the magic tickets based on the similar coding endeavors here and here and here.
You can find these cookies in Safari by opening the Storage tab of Developer tools (you can turn on developer tools in preferences), and looking under espn.com in the Cookies folder. In Chrome, you can go to Preferences -> Advanced -> Content Settings -> Cookies -> See all cookies and site data, and looking for ESPN.
-
-
Depending on what web browser (Firefox, Chrome, Edge, Brave, etc.) you are using, the process for viewing your session cookies in the web inspector will be different. I recommend Googling "how to inspect element in [browser]" (for your specific browser) to learn how to use that browser's web inspector.
-
Copy the file
EXAMPLE-private.json
(located in theauth/espn/
directory), and rename the file copyprivate.json
, then copy and paste the above cookies into their respective fields. Please note, theswid
will be surrounded by curly braces ({...}
), which must be included.
-
-
NOTE: *Because ESPN made the change to their API between 2018 and 2019, ESPN support in the Fantasy Football Metrics Weekly Report application is currently limited to the 2019 season and later. Support for historical seasons will be implemented at a later time.
-
You are now ready to generate a report!
-
If you are running on macOS, see below!
-
If you followed the setup instructions and set up the application to run in a virtual environment, once you have navigated to the project directory, you MUST run
workon fantasy-football-metrics-weekly-report
before running the report EVERY TIME you open a new command line prompt to run the application!
-
Make sure you have updated the default league ID (
league_id
value) in theconfig.ini
file to your own league id. Please see the respective setup instructions for your chosen platform for directions on how to find your league ID. -
Run
python main.py
. You should see the following prompts:-
Generate report for default league? (y/n) ->
.Type
y
and hit enter. -
Generate report for default week? (y/n) ->
.Type
y
and hit enter. -
The FIRST time you run the app, a browser window will automatically open, and if you correctly followed the instructions in the Report Setup section, you should see a verifier code (something like
w6nwjvz
). -
Copy the above verifier code and return to the command line window, where you should now see the following prompt:
Enter verifier :
Paste the verifier code there and hit enter.
-
Assuming the above went as expected, the application should now generate a report for your fantasy league for the selected NFL week.
-
NOTE: You can also specify a large number of configuration options directly in the command line. Please see the usage section for more information.
If you are running on macOS, there is an additional bash script available in the project, run_in_virtualenv.command. This script allows you to double-click it and run the app in a new Terminal window. It REQUIRES you to have completed all steps in Setup, and also the above steps in Running the Report Application, with the exception of running the workon
command or the python main.py
command. Instead, do the following:
-
Right click on run_in_virtualenv.command and select
Open With
, then selectTextEdit
. -
Modify the path you find in the script after
cd
to point to wherever you cloned the application. You can either use the absolute path (something like/Users/username/Projects/fantasy-football-metrics-weekly-report
), or a shortcut to your home directory (~
), like~/Documents/fantasy-football-metrics-weekly-report
). -
Move run_in_virtualenv.command wherever you wish it to be for easy access.
-
You can now double-click run_in_virtualenv.command and it will open a new Terminal window and run the application! If that fails, you may need to change the permissions on run_in_virtualenv.command. You can do that as follows:
-
Open a Terminal window.
-
Run
cd path/to/wherever/you/put/run_in_virtualenv.command
-
Run
chmod +x run_in_virtualenv.command
-
If you get a permissions error after running the
chmod
command, you may need to run it as an administrator:sudo chmod +x run_in_virtualenv.command
And then put in your password to allow the operating system to modify the permissions on run_in_virtualenv.command.
-
NOW you should be able to double-click run_in_virtualenv.command to launch the application!
-
The Fantasy Football Metrics Weekly Report application allows certain aspects of the generated report to be configured with a .ini
file. Included in the repository is EXAMPLE-config.ini
, containing default values, as well as league settings that point to a public Yahoo league as a "demo" of the app.
The app REQUIRES that config.ini
be present, so you will need to rename EXAMPLE-config.ini
to just config.ini
. Then update the values to reflect the league for which you wish to generate a report, as well as any other settings you wish to change from the default values.
For those of you who wish to configure the report to include a custom subset of the available features (for instance, if you want league stats but not team pages, or if you want score rankings but not coaching efficiency), the Report
section in the config file allows all features to be turned on or off. You must use a boolean value (True
or False
) to turn on/off any of the available report features, which are the following:
league_standings = True
league_playoff_probs = True
league_power_rankings = True
league_z_score_rankings = True
league_score_rankings = True
league_coaching_efficiency_rankings = True
league_luck_rankings = True
league_weekly_top_scorers = True
league_weekly_highest_ce = True
league_bad_boy_rankings = True
league_beef_rankings = True
report_time_series_charts = True
report_team_stats = True
team_points_by_position_charts = True
team_bad_boy_stats = True
team_beef_stats = True
team_boom_or_bust = True
The report can also have some of its visual formatting configured. The following formatting options are available:
font = helvetica
font_size = 12
The values seen in the supported_fonts
configuration option are the currently supported fonts for the app.
The player headshots retrieved for individual team pages can come in varying resolutions, and when they are extremely high resolution, they can inflate the size of the report PDF. In order to allow the user to reduce the size of the final report PDF if desired, the following option is available:
image_quality = 75
The default value for the image quality is 75%, allowing for a reasonable reduction in image size without sacrificing overall aesthetic quality. However, this value can be set on a scale of 0%-100%, depending on the preferences of the user.
Once the initial images have been retrieved and quality has been adjusted, the report will cache those images and continue to use those indefinitely until you delete the output/data/<YEAR>/<LEAGUE_ID>/week_<WEEK_#>/player_headshots
for that week, since otherwise the images would continue to have their quality reduced until the headshots degraded entirely.
In addition to turning on/off the features of the report PDF itself, there are additional configuration options, which are as follows:
Option | Description |
---|---|
platform |
Fantasy football platform for which you are generating a report. |
supported_platforms |
Comma-delimited list of currently supported fantasy football platforms. |
league_id |
The league id of the fantasy football for which you are running the report. |
game_id |
Game id by season (see: Game Resource for Yahoo) |
data_dir |
Directory where saved data is stored. |
output_dir |
Directory where generated reports are created. |
chosen_week |
Selected NFL season week for which to generate a report. |
num_playoff_simulations |
Number of Monte Carlo simulations to run for playoff predictions. The more sims, the longer the report will take to generate. |
bench_positions |
Comma-delimited list of available bench positions in your league. |
prohibited_statuses |
Comma-delimited list of possible statuses in your league that indicate a player was not able to play (only needed if you plan to utilize the automated coaching efficiency disqualification functionality). |
initial_faab_budget |
Set the initial FAAB (Free Agent Acquisition Budget) for Yahoo leagues, since this information does not seem to be exposed in the API. |
num_teams |
Number of teams in selected league. |
num_regular_season_weeks |
Number of regular season weeks in selected league. |
num_playoff_slots |
Number of playoff slots in selected league. |
num_playoff_slots_per_division |
Numbers of teams per division that qualify for the playoffs. |
coaching_efficiency_disqualified_teams |
Teams manually DQed from coaching efficiency rankings (if any). |
yahoo_auth_dir |
Directory where Yahoo OAuth accesses and stores credentials and refresh tokens. |
google_drive_upload |
Turn on (True ) or off (False ) the Google Drive upload functionality. |
google_auth_token |
Google OAuth refresh token. |
google_drive_root_folder_name |
Online folder in Google Drive where reports are uploaded. |
reupload_file |
File path of selected report that you wish to re-upload to Google Drive by running upload_to_google_drive.py as a standalone script. |
post_to_slack |
Turn on (True ) or off (False ) the Slack upload functionality. |
slack_auth_token |
Slack authentication token. |
post_or_file |
Choose whether you post a link to the generated report on Slack (set to post ), or upload the report PDF itself to Slack (set to file ). |
slack_channel |
Selected Slack channel where reports are uploaded. |
notify_channel |
Turn on (True ) or off (False ) using the @here slack tag to notify chosen Slack channel of a posted report file. |
repost_file |
File path of selected report that you wish to repost to Slack. |
After completing the above setup and configuration steps, you should now be able to simply run python main.py
to regenerate a report. The report generator script (main.py
) also supports several command line options that allow you to specify the following:
Flag | Description |
---|---|
-h, --help |
Print command line usage message |
-l, --fantasy-platform <platform> |
Fantasy football platform on which league for report is hosted. |
-l --league-id <league_id> |
Fantasy Football league ID |
-w --week <week> |
Chosen week for which to generate report |
-g --game-id <game_id> |
Chosen fantasy game id for which to generate report. Defaults to "nfl", interpreted as the current season if using Yahoo. |
-y, --year <year> |
Chosen year (season) of the league for which a report is being generated. |
-s, --save-data |
Save all retrieved data locally for faster future report generation |
-s, --refresh-web-data |
Refresh all web data from external APIs (such as bad boy and beef data) |
-p, --playoff-prob-sims <int> |
Number of Monte Carlo playoff probability simulations to run." |
-b, --break-ties |
Break ties in metric rankings |
-q, --disqualify-ce |
Automatically disqualify teams ineligible for coaching efficiency metric |
-d, --dev-offline |
Run OFFLINE (for development). Must have previously run report with -s option. |
-t, --test |
Generate TEST report (for development) |
When you are done working within the virtualenv
, you can run deactivate
within the environment to exit:
(fantasy-football-metrics) host-machine: fantasy-football-metrics-weekly-report $ deactivate
When you wish to work within the virtualenv
once more, do the following:
-
Run
source ~/.bashrc
-
View
virtualenvs
that you have available:lsvirtualenv
-
Run
workon fantasy-football-metrics-weekly-report
(or whatever you named your virtual environment for the application).
The Fantasy Football Metrics Weekly Report application also supports several additional integrations if you choose to utilize them. Currently it is capable of uploading your generated reports to Google Drive, and also directly posting your generated reports to the Slack Messenger app.
The Fantasy Football Metrics Weekly Report application includes Google Drive integration, allowing your generated reports to be uploaded and stored in Google Drive, making it easy to share the report with all league members.
The following setup steps are required in order to allow the Google Drive integration to function properly:
-
Log in to your Google account (or make one if you don't have one).
-
Create a new project in the Google Developers Console.
-
Accept the terms & conditions.
-
Name your project, something like
ff-report-drive-uploader
, but it can be anything you like. -
Click "CREATE".
-
It will take a few moments for the project to be created, but once it is there will be a notification.
-
Go to the Google Developers Console.
-
Your new project should automatically load in the dashboard, but in the event it does not or you have other projects (a different project might load by default), click the project name on the top left of the page (to the right of where it says "Google APIs"), and select your new project.
-
Either click the
+ ENABLE APIS AND SERVICES
button on the top of the page, or select "Library" from the menu on the left, search for "Google Drive API", and click "Google Drive API" when it comes up. -
Click
ENABLE
. -
After a moment it will be enabled. Click "Credentials" from the left menu and then click "Create Credentials".
-
From the menu that drops down, select "OAuth client ID".
-
Click on "Configure Consent Screen".
-
Put
yff-report-drive-uploader
inApplication name
. -
Click
Add Scope
, check the box next to the../auth/drive
scope, and clickADD
. -
Click
SAVE
at the bottom of the screen. -
Now go click "Credentials" again from the left menu and then click "Create Credentials", then select "OAuth client ID".
-
Select "Other" from the radio buttons, and put
yff-report-drive-uploader-client-id
. -
Click "Create".
-
A popup with your
client ID
andclient secret
will appear. Click "OK". -
On the far right of your new credential, click the little arrow that displays "Download JSON" when you hover over it.
-
Your credentials JSON file will download. Rename it
credentials.json
, and put it in theauth/google/
directory whereEXAMPLE-credentials.json
is located. -
Open a terminal window and run
python resources/google_quickstart.py
. -
A browser window will open asking you to either select a Google account to log into (if you have multiple) or log in. Select your account/login.
-
A warning screen will appear saying "This app isn't verified". Click "Advanced" and then "Go to yff-report-drive-uploader (unsafe)" (this screen may vary depending on your web browser, but the point is you need to proceed past the warning).
-
On the next screen, a popup saying "Grant yff-report-drive-uploader permission" will appear. Click "Allow", then "Allow" again on the following "Confirm your choices" screen.
-
You will see a screen that says only "The authentication flow has completed.", which you can close.
-
Go back to your terminal window where you ran
python resources/google_quickstart.py
. It should have printed "Authentication successful.", as well as a list of 10 files in your Google Drive to confirm it can access your drive. It will also have automatically generated atoken.json
file inauth/google/
, which you should just leave where it is and do NOT edit or modify in any way! -
You can now upload your reports to Google Drive, either by changing the value of
google_drive_upload
toTrue
inconfig.ini
, or by setting the value ofreupload_file
inconfig.ini
to the filepath of the report you wish to upload, opening a Terminal window, and runningpython integrations/drive.py
.
The Fantasy Football Metrics Weekly Report application includes integration with the poplular personal and business chat app Slack, allowing your generated reports (or links to where they are stored on Google Drive) to be uploaded directly to Slack, making it easy to share the report with all league members.
The following setup steps are required in order to allow the Slack integration to function properly:
-
Sign in to your slack workspace here.
-
Once logged in, you need to create a new app for your workspace.
-
After the popup appears, fill in the fields as follows:
-
App Name
:ff-report
(this name can be anything you want) -
Development Slack Workspace
: Select your chosen Slack workspace from the dropdown menu.
-
-
Click
Create App
. You should now be taken to the page for your new app, where you can configure things like the app title card color, the icon, the description, as well as a whole host of other features (see here for more information). -
Select
Basic Information
from the menu on the left. -
Scroll down to
Display Information
and set up your Slack app with whatever display settings you want. -
Scroll up to
Building Apps for Slack
and clickBots
. -
You will be taken to the
App Home
section of the menu on the left. -
Click the
Review Scopes to Add
button. -
You will be taken to the
OAuth & Permissions
section of the menu on the left. -
Scroll down to
Scopes
. -
Under
Bot Token Scopes
, click theAdd an OAuth Scope
button. -
From the dropdown menu, select the below scopes:
OAuth Scope | Description |
---|---|
channels:read |
View basic information about public channels in the workspace |
chat:write |
Send messages as @ff-report |
chat:write.customize |
Send messages as @ff-report with a customized username and avatar |
chat:write.public |
Send messages to channels @ff-report isn't a member of |
files:write |
Upload, edit, and delete files as ff-report |
groups:read |
View basic information about private channels that ff-report has been added to |
im:read |
View basic information about direct messages that ff-report has been added to |
incoming-webhook |
Post messages to specific channels in Slack |
mpim:read |
View basic information about group direct messages that ff-report has been added to |
-
Scroll back up to
OAuth Tokens & Redirect URLs
, and now you should be able to click theInstall App to Workspace
button, so click it. -
You will be redirected to a screen saying your app is asking for permission to access the Slack workspace, and presenting you with a dropdown to select a channel for your app to post to. Select your desired channel, and hit
Allow
. -
You will now be redirected back to the
OAuth & Permissions
section of your app settings. At the top, you will see aBot User OAuth Access Token
field, which will now have a value populated. -
Copy the file
EXAMPLE-token.json
(located in theauth/slack/
directory), and rename the file copytoken.json
, then copy and paste the aboveBot user OAuth Access Token
into the field value oftoken.json
where it says"SLACK_APP_OAUTH_ACCESS_TOKEN_STRING"
, replacing that string. Make sure you are using douple quotes ("
) on either side of your token string. -
You can now upload your reports to Slack, either by updating the following values in
config.ini
:-
post_to_slack = True
-
slack_channel = channel-name
(this can be set to whichever channel you wish to post (as long as the user who created the app has access to that channel)
Or by setting the value of
repost_file
inconfig.ini
to the filepath of the report you wish to upload, opening a Terminal window, and runningpython integrations/slack.py
. -
In addition to printing output from the application to the commadn line, the Fantasy Football Metrics Weekly Report also logs all of the same output to out.log, which you can view at any time to see output from past runs of the application.
Occasionally when you use the Yahoo fantasy football API, there are hangups on the other end that can cause data not to transmit, and you might encounter an error similar to this:
Traceback (most recent call last):
File "yfpy-app.py", line 114, in <module>
var = app.run()
File "/Users/your_username/PATH/T0/LOCAL/PROJECT/yfpy-app.py", line 429, in run
for team in team_standings:
IndexError: list index out of range
Typically when the above error (or a similar error) occurs, it simply means that one of the Yahoo Fantasy Football API calls failed and so no data was retrieved. This can be fixed by simply re-running data query.