Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 22 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ Note: App will restart when you change any variable so your chat room may be sem
- INIT_MSG: The message that the bot will say when it is started (“Hi” by default, can be blank for no message)
- ESPN_S2: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- SWID: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- ESPN_USERNAME: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation **Experimental, may not work**
- ESPN_PASSWORD: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation **Experimental, may not work**

After you have setup your variables you will need to turn it on. Navigate to the "Resources" tab of your Heroku app Dashboard.
You should see something like below. Click the pencil on the right and toggle the buton so it is blue like depicted and click "Confirm."
Expand All @@ -154,37 +156,39 @@ You're done! You now have a fully featured GroupMe/Slack/Discord chat bot for ES
Unfortunately to do auto deploys of the latest version you need admin access to the repository on git. You can check for updates on the github page (https://github.com/dtcarls/ff_bot/commits/master) and click the deploy button again; however, this will deploy a new instance and the variables will need to be edited again.

#### Private Leagues
For private league you will need your username and password or your swid and espn_s2.
You can find swid and espn_s2 values after logging into your espn fantasy football account on espn's website.
(Chrome Browser)
Right click anywhere on the website and click inspect option.
From there click Application on the top bar.
On the left under Storage section click Cookies then http://fantasy.espn.com.
From there you should be able to find your swid and espn_s2 variables and values.
For private league you will need to get your swid and espn_s2.
You can find these two values after logging into your espn fantasy football account on espn's website.
(Chrome Browser)
Right click anywhere on the website and click inspect option.
From there click Application on the top bar.
On the left under Storage section click Cookies then http://fantasy.espn.com.
From there you should be able to find your swid and espn_s2 variables and values.

There is a new **Experimental (may not work)** option to use a username and password for espn to access private leagues instead of having to use swid and s2.

## Troubleshooting / FAQ

**League must be full.**

The bot isn't working
Did you miss a step in the instructions? Try doing it from scratch again. If still no luck, post here so the answer can be shared with others.
The bot isn't working
Did you miss a step in the instructions? Try doing it from scratch again. If still no luck, open an issue (https://github.com/dtcarls/fantasy_football_chat_bot/issues) so the answer can be shared with others.

How are power ranks calculated?
How are power ranks calculated?
They are calculated using 2 step dominance, as well as a combination of points scored and margin of victory. Weighted 80/15/5 respectively. I wouldn't so much pay attention to the actual number but more of the gap between teams. Full source of the calculations can be seen here: https://github.com/cwendt94/ff-espn-api/commit/61f8a34de5c42196ba0b1552aa25282297f070c5

Is there a version of this for Yahoo/CBS/NFL/[insert other site]?
Is there a version of this for Yahoo/CBS/NFL/[insert other site]?
No, this would require a significant rework for other sites.

I'm not getting the init message
I'm not getting the init message
Are you sure you flipped the switch in Heroku to activate the worker (the toggle should be blue)? The other common mistake is misconfigured environment variables.

I keep getting the init message
I keep getting the init message
Remove your init message and it will stop. The init message is really for first setup to ensure it is working.

How do I set another timezone?
How do I set another timezone?
Specify your variable https://en.wikipedia.org/wiki/List_of_tz_database_time_zones#List

Is there a version of this for Messenger/WhatsApp/[insert other chat]?
Is there a version of this for Messenger/WhatsApp/[insert other chat]?
No, but I am open to pull requests implementing their API for additional cross platform support.

## Getting Started for development and testing
Expand Down Expand Up @@ -222,11 +226,11 @@ python3 setup.py install
- END_DATE: This is when the bot will stop paying attention and stop sending messages to your chat. (2019-12-30 by default)
- LEAGUE_YEAR: ESPN League year to look at (2019 by default)
- TIMEZONE: The timezone that the messages will look to send in. (America/New_York by default)
- INIT_MSG: The message that the bot will say when it is started (“Hi” by default, can be blank for no message)
- ESPN_USERNAME: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- ESPN_PASSWORD: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- INIT_MSG: The message that the bot will say when it is started (“Hi” by default, can be blank for no message)
- ESPN_S2: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- SWID: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation
- ESPN_USERNAME: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation **Experimental, may not work**
- ESPN_PASSWORD: Used for private leagues. See [Private Leagues Section](#private-leagues) for documentation **Experimental, may not work**

### Running with Docker

Expand Down
12 changes: 6 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"chat bot",
"ff"
],
"website": "https://github.com/dtcarls/ff_bot/",
"repository": "https://github.com/dtcarls/ff_bot/",
"website": "https://github.com/dtcarls/fantasy_football_chat_bot/",
"repository": "https://github.com/dtcarls/fantasy_football_chat_bot/",
"env": {
"BOT_ID": {
"description": "GroupMe Bot ID",
Expand All @@ -31,23 +31,23 @@
},
"LEAGUE_YEAR": {
"description": "ESPN League Year",
"value": "2019"
"value": "2020"
},
"TIMEZONE": {
"description": "League timezone for sending messages",
"value": "America/New_York"
},
"START_DATE": {
"description": "Season Start Date",
"value": "2019-09-04"
"value": "2020-09-10"
},
"END_DATE": {
"description": "Season End Date",
"value": "2019-12-30"
"value": "2020-12-30"
},
"INIT_MSG": {
"description": "Bot Init Message",
"value": "Hi"
"value": "Successfully installed https://github.com/dtcarls/fantasy_football_chat_bot you can now remove this init_msg"
}
}
}
17 changes: 12 additions & 5 deletions ff_bot/ff_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def get_projected_total(lineup):
else:
total_projected += i.projected_points
return total_projected

def all_played(lineup):
for i in lineup:
if i.slot_position != 'BE' and i.game_played < 100:
Expand Down Expand Up @@ -272,15 +272,22 @@ def bot_main(function):
except KeyError:
espn_s2 = '1'

username = os.environ.get("ESPN_USERNAME")
password = os.environ.get("ESPN_PASSWORD")
try:
espn_username = os.environ["ESPN_USERNAME"]
except KeyError:
espn_username = '1'

try:
espn_password = os.environ["ESPN_PASSWORD"]
except KeyError:
espn_password = '1'

bot = GroupMeBot(bot_id)
slack_bot = SlackBot(slack_webhook_url)
discord_bot = DiscordBot(discord_webhook_url)

if username and password:
league = League(league_id=league_id, year=year, username=username, password=password)
if espn_username and espn_password:
league = League(league_id=league_id, year=year, username=espn_username, password=espn_password)
elif swid == '{1}' and espn_s2 == '1':
league = League(league_id=league_id, year=year)
else:
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
flake8==3.3.0
apscheduler>=3.3.0
requests>=2.0.0,<3.0.0
espn_api>=0.4.0
espn_api>=0.4.2
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,15 @@

include_package_data=True,

version='0.2.1',
version='0.3.0',

description='ESPN fantasy football GroupMe Bot',

author='Dean Carlson',

author_email='[email protected]',

install_requires=['requests>=2.0.0,<3.0.0', 'ff_espn_api>=1.1.6', 'apscheduler>3.0.0'],
install_requires=['requests>=2.0.0,<3.0.0', 'espn_api>=0.4.2', 'apscheduler>3.0.0'],

test_suite='nose.collector',

Expand Down