r/FantasyPL • u/esoemah 146 • Apr 05 '19
Updating & adding new features to FantasyPL_bot
EDIT 2019-08-09: THE BOT IS NOT CURRENTLY LIVE (YET) - WILL BE LIVE TONIGHT / TOMORROW.
Back when I first made the price change bot I was really new to coding and so it was pretty shit. So when people asked me if I would open source it, I would hesitate, because I was too embarrassed about how bad it was (here's a picture of it for anyone interested -- this isn't even the 1st version, so it was worse before).
Since I've been getting really into open source development, and wanting to improve my programming skills, I decided (a couple of months ago) to rework the bot and make it open source. It's now only dependent on FPL's API and not http://fplstatistics.co.uk/ like before, which unfortunately means we will have to say goodbye to the Cumbrian Bungalow :(.
While updating the bot, I also thought it would be cool to add some additional stuff, such as commands that can be used by anyone on this subreddit for comparing players in e.g. the RMT thread. I finished this about a month ago, but got distracted creating a Python package for Understat, exams and other stuff. I've finally got round to setting it up on a droplet now, and it should be running using tmux.
Usage
The bot can be called on /r/FantasyPL using the following two commands:
!fplbot <player_name> vs. <team_name> <optional: number of fixtures>!fplbot <player_name> vs. <player_name> <optional: number of fixtures>
The bot uses text indexes to search for the player(s) and using a manually created mapping (so you don't have to use e.g. "man utd" exactly, but other variations are fine as well, like "man u" or "manchester united"). The number of fixtures is completely optional, and if not specified, it simply uses all fixtures that are considered relevant (so it can result in a huge comment, be warned!). All the data is taken from FPL's API & Understat. Here are two examples:
!fplbot heung-min son vs. mane 5Son (£8.9) vs. Mané (£9.6) (last 5 fixtures)
| xA | A | xG | G | MP | Fixture | Fixture | MP | G | xG | A | xA |
|---|---|---|---|---|---|---|---|---|---|---|---|
| 0.13 | 0 | 0.42 | 1 | 90 | Spurs 3-1 Leicester | Liverpool 3-0 Bournemouth | 89 | 1 | 0.58 | 0 | 0.12 |
| 0.70 | 0 | 0.19 | 1 | 90 | Spurs 1-0 Newcastle United | West Ham 1-1 Liverpool | 90 | 1 | 0.64 | 0 | 0.00 |
| 0.00 | 0 | 0.20 | 1 | 90 | Spurs 2-1 Watford | Liverpool 1-1 Leicester | 90 | 1 | 0.18 | 0 | 0.10 |
| 0.38 | 0 | 0.05 | 0 | 90 | Spurs 0-1 Man Utd | Liverpool 4-3 Crystal Palace | 90 | 1 | 0.47 | 0 | 0.01 |
| 0.08 | 1 | 0.50 | 1 | 77 | Cardiff 0-3 Spurs | Brighton 0-1 Liverpool | 90 | 0 | 0.10 | 0 | 0.10 |
| 1.29 | 1 | 1.36 | 4 | 437 | 449 | 4 | 1.97 | 0 | 0.34 |
2.
!fplbot rashford vs liverpoolRashford vs. Liverpool (last 4 fixtures)
| Fixture | Date | MP | G | xG | A | xA | NPG | NPxG | KP |
|---|---|---|---|---|---|---|---|---|---|
| Liverpool 3-1 Man Utd | 2018-12-16 | 90 | 0 | 0.02 | 0 | 0.00 | 0 | 0.02 | 0 |
| Man Utd 2-1 Liverpool | 2018-03-10 | 72 | 2 | 0.17 | 0 | 0.00 | 2 | 0.17 | 0 |
| Liverpool 0-0 Man Utd | 2017-10-14 | 24 | 0 | 0.00 | 0 | 0.00 | 0 | 0.00 | 0 |
| Liverpool 0-0 Man Utd | 2016-10-17 | 78 | 0 | 0.00 | 0 | 0.00 | 0 | 0.00 | 0 |
| 264 | 2 | 0.19 | 0 | 0.00 | 2.0 | 0.19 | 0 |
I haven't run it for long times on end, and haven't really tested it thoroughly, so it might crash / not work sometimes. If this happens I'll try to get it back up and running ASAP, but I just started my thesis so might not have enough time. Also, fyi it updates the database every day after posting the price changes, so if you try and use it directly after a game has ended, it won't show up.
Suggestions & feedback
Obviously there are many things that can be improved (I should use the Understat package I made in the bot's code for example), so if you have any suggestions for e.g. additional commands, better formatting or whatever (like idk if I should add FPL's points to the table as well), then just let me know. You can either leave a comment here, message me, or best of all, create an issue on https://github.com/amosbastian/FPLbot/issues.
40
u/TrustMe_I_lie 335 Apr 05 '19
This is EXCELLENT! Thanks for all your work. Just like daily price change bot has become the staple of this sub. This new tool will soon be widely used during discussion threads and in RMTs!
!fplbot Aubameyang vs Everton 5
24
u/-Yngin- 104 Apr 05 '19
I can't believe the era of the Cumbrian Bungalow has come to an end. I was here for its conception and now for its demise. It was a good run, CB. May you be rented out for eternity.
But seriously, awesome job mate! This is going to be great!
12
u/Myfantasyredditacct 8 Apr 05 '19
This is really great work.
My suggestion would be if you could stack the player comparison tables. Currently it is not mobile friendly.
So possibly this:
Son (£8.9) vs. Mané (£9.6) (last 2 fixtures)
Son
Mané
5
u/wernerhedgehog 122 Apr 05 '19
Thanks for all your work. Also am at an amateur stage in python, so your write up was pretty encouraging.
Now I need to decide if I should play brooks or Harvey Barnes. Guess its a good test case since there are 2 barnes.
4
u/ar7hurp1r35 1 Apr 05 '19
!fplbot mane vs southampton
•
u/[deleted] Apr 05 '19
Amazing work. I've added this into the sidebar and also the daily thread from tomorrow.
10
u/[deleted] Apr 05 '19
!fplbot Tielemans vs. Maddison 5
5
u/Trailer_Park_Jihad 517 Apr 05 '19
Can we all chip in and make the Cumbrian Bungalow a shared refuge for all FPL addicts?
An FPL crack house, if you will.
5
u/Trailer_Park_Jihad 517 Apr 05 '19
Not an issue I'm particularly concerned about, but thought it would be worth mentioning.
Would it be possible to use the FPL site for assists? Tielemans has 4 assists according to FPL, but 3 assists according to understat. FPL has a much looser definition for assists so maybe it would be better to use their statistics on assists for the bot?
4
u/KanteIsTheGOAT 3 Apr 05 '19
Will be popular I guess so here goes !fplbot Hazard vs. Salah 5
1
u/iMMoss13 Aug 19 '19
!fplbot sterling v Bournemouth
2
u/HakunaPatata 38 Apr 05 '19
!fplbot Hazard vs. Mane 5
2
u/[deleted] Apr 05 '19
!fplbot Aubameyang vs. Lacazette 5
2
u/Borken89 6 Apr 05 '19
Really awesome bot!
2
u/doAs1Say Apr 05 '19
Please add FPL points to the tables. At the end of day, that is all everyone is trying to maximise. Well done on the bot!
2
u/liberalfamilia 163 Apr 05 '19
Holy forking balls, this is beautiful.
2
u/HellomynameisSteven 1 Apr 05 '19
Saw you use this in a thread recently and thought it was brilliant. Top work!
2
u/TheBadAimGuy 9 Apr 05 '19
Leave your F's here everyone. Gone, but not forgotten.
1
u/Borken89 6 Apr 05 '19
!fplbot heung-min son vs. bernardo silva 5
1
u/adishriLFC 9 Apr 05 '19
!fplbot Salah vs. Southampton 3
1
u/Borken89 6 Apr 05 '19
!fplbot vardy vs huddersfield
1
u/Borken89 6 Apr 05 '19
!fplbot vardy vs. mane 5
1
u/SpaceSheep1212 9 Apr 05 '19
!fplbot Son vs. Eriksen 5
1
u/SpaceSheep1212 9 Apr 05 '19
!fplbot Salah vs. Mane 5
1
u/Trailer_Park_Jihad 517 Apr 05 '19
!fplbot Digne vs. Wan-Bissaka
1
u/Inalek 5 Apr 05 '19
!fplbot Hazard vs. West Ham 15
1
u/PercyTheWeasel 105 Apr 05 '19
!fplbot Chilwell vs. Pereira 5
1
u/-Yngin- 104 Apr 05 '19
!fplbot Ederson vs. Kepa 5
1
u/M0nkeyK0ng 1 Apr 05 '19
!fplbot Fraser vs. Tielemans 5
1
u/rafello Apr 05 '19
!fplbot Wan-Bissaka vs. Newcastle
1
u/KevindeBacon 1 Apr 05 '19
Well done man! Thanks.
!fplbot Kane vs Aguero 3
1
u/nttin710 Apr 06 '19
!fplbot Ramsey vs Everton 5
1
u/swaiii 9 Apr 06 '19
!fplbot lacazette Vs. Aguero
1
u/swaiii 9 Apr 06 '19
!fplbot lacazette vs. Agüero 5
1
u/ThaiDivingGuru 4 Apr 06 '19
!fplbot Valery vs Bertrand 8
1
u/M0nkeyK0ng 1 Apr 06 '19
!fplbot Kolasinac vs Monreal 8
1
u/M0nkeyK0ng 1 Apr 06 '19
!fplbot Jonny vs Bennett 8
1
u/Sean8162 70 Apr 06 '19
Really awesome job. Will you be planning on updating so that keepers can be compared using the bot? Or is that a step too far atm?
1
u/Dczieta Apr 07 '19
Great work! My suggestion would be to add a total points accumulated in the period for lazy people like myself
1
u/cooperj 2 Apr 07 '19
!fplbot aguero vs. firmino 8
1
u/RomeMe1122 65 Apr 07 '19
!fplbot Jota vs McNeil 5
1
u/RomeMe1122 65 Apr 07 '19
!fplbot Aguero vs Spurs 5
1
u/RomeMe1122 65 Apr 07 '19
!fplbot Aguero vs Man U
1
u/RomeMe1122 65 Apr 07 '19
!fplbot Aguero vs Crystal Palace
1
u/jvsth3re 10 Apr 09 '19
!fplbot Pogba vs. West Ham 5
1
u/GymSkipperRoy 4 Apr 10 '19
!fplbot mané vs. Deulofeu 10
1
u/TheBadAimGuy 9 Apr 10 '19
!fplbot Jimenez vs Lacazette 7
1
u/Lodowson 3 Apr 11 '19
!fplbot Bernardo vs. Valery 5
1
u/Lodowson 3 Apr 11 '19
!fplbot kiko femina vs. valery 3
1
u/GymSkipperRoy 4 Apr 11 '19
!fplbot firmino Vs mané
1
u/GymSkipperRoy 4 Apr 11 '19
!fplbot Firmino Vs Lacazette
1
u/[deleted] Apr 12 '19
!fplbot de bruyne vs. pogba 5
1
u/AnanyRoger Apr 12 '19
!fplbot Duffy vs Dunk 5
1
u/RomeMe1122 65 Apr 12 '19
!fplbot Sigurdsson vs Fulham
1
u/RomeMe1122 65 Apr 12 '19
!fplbot Vardy vs Newcastle
1
u/RomeMe1122 65 Apr 12 '19
!fplbot Eriksen vs Huddersfield
1
u/TheNalamaru 4 Apr 12 '19
!fplbot Aguero vs Valery 20
1
u/RomeMe1122 65 Apr 12 '19
!fplbot Son vs Sterling 4
1
u/Ottoeder 90 Apr 14 '19
!fplbot Valery vs Bednarek
1
u/muzz_mm 1 Apr 15 '19
!fplbot Son vs. Maddison 5
1
u/McRebel42 2 Apr 16 '19
!fplbot Aubameyang vs. Lacazette 10
1
u/McRebel42 2 Apr 16 '19
!fplbot Aubameyang vs Lacazette 10
1
u/GymSkipperRoy 4 Apr 17 '19
!fplbot Success Vs Gray 20
1
u/E60LNDN Apr 18 '19
!fplbot Pogba vs. Everton 5
1
u/mrstewiegriffin 9 Apr 18 '19
!fplbot Sterling vs. Kevin De Bruyne
1
u/AwareGarlic 3 Apr 18 '19
!fplbot Jimenez vs Lacazette
1
u/GymSkipperRoy 4 Apr 19 '19
!fplbot Eriksen vs. De Bruyne 5
1
u/blinkinghell Apr 19 '19
!fplbot sterling vs. jimenez 5
1
u/GymSkipperRoy 4 Apr 23 '19
!fplbot Milivojevic vs. Sigurdsson 10
1
u/GymSkipperRoy 4 Apr 23 '19
!fplbot Milivojevic Vs. Bernardo Silva 10
1
u/GymSkipperRoy 4 Apr 23 '19
!fplbot Sigurdsson Vs. Llorente 3
1
u/GymSkipperRoy 4 Apr 24 '19
!fplbot Sigurdsson vs. Llorente 5
1
u/GymSkipperRoy 4 Apr 24 '19
!fplbot Sigurdsson vs. Bernardo Silva
1
u/GymSkipperRoy 4 Apr 26 '19
!fpl babel vs. zaha 10
1
u/Rodriguez79 6 Apr 26 '19
!fplbot Sane vs. Bernardo Silva 5
1
u/Harvardsports 100 Apr 30 '19
It's shocking how useful stuff like this gets 129 upvotes but one generic meme gets 500+
1
u/Thisbb 20 May 03 '19
!fplbot luke shaw vs Patrick van aanholt
1
u/Redx86x May 03 '19
!fplbot Jimenez Vs Jota 5
1
u/Redx86x May 03 '19
!fplbot Jimenez vs Jota 5
1
u/RomeMe1122 65 May 05 '19
!fplbot David Silva vs Bernardo Silva 5
1
u/RomeMe1122 65 May 09 '19
!fplbot Laporte vs Walker 5
1
u/gmbedoyal May 11 '19
!fplbot arnautovic vs. wilson 5
1
u/[deleted] May 21 '19
!fplbot Aubameyang vs Everton 5
1
u/[deleted] May 21 '19
!fplbot Tielemans vs. Maddison 5
1
u/RomeMe1122 65 Jun 27 '19
!fplbot King vs Wilson 5
1
u/dbarfield Jul 01 '19
!fplbot Mane vs. Salah
1
u/[deleted] Jul 03 '19
!fplbot Digne vs. Coleman 6
1
u/[deleted] Jul 03 '19
!fplbot Digne vs. Azpilicueta 6
1
u/Abrarmustang Jul 11 '19
!fplbot <salah> vs. <sterling> <optional: 5>
1
u/superlord354 289 Jul 14 '19
!fplbot Zaha vs Felipe Anderson
1
u/Kjkjkjkj1984 32 Jul 16 '19
!fplbot kane vs aguero 20
1
u/ronit434 redditor for <30 days Jul 18 '19
!fplbot ayoze perez vs. ryan fraser 10
1
u/Pikkhaud 1 Jul 19 '19
!fplbot heung-min son vs. mane 5
1
u/Pikkhaud 1 Jul 19 '19
!fplbot Brooks vs. Barnes 5
1
u/GymSkipperRoy 4 Jul 23 '19
!fplbot digne vs. Coleman 10
1
u/ibmal 23 Jul 27 '19
!fplbot Fornals vs. Ceballos 10
1
u/ElderHallow 14 Aug 01 '19
!fplbot <Fabianski> vs. <Heaton>
1
u/ElderHallow 14 Aug 01 '19
!fplbot Fabianski vs. Heaton
1
u/yehianegm27 redditor for <1 day Aug 04 '19 edited Aug 04 '19
!fplbot De Bruyne vs. Sterling 5
1
u/yehianegm27 redditor for <1 day Aug 04 '19
!fplbot sterling vs. pogba 5
1
u/AsTheRomansSaid Aug 08 '19
!fplbot Richarlison vs. Sigurdsson 10
1
u/leomes123 4 Aug 08 '19
!fplbot <Grealish> vs. <Dendoncker>
1
u/pmrox 46 Aug 08 '19
!fplbot Raheem Sterling vs. west ham 4
1
u/pmrox 46 Aug 08 '19
!fplbot Kevin de bruyne vs. west ham 4
1
u/jaydsmith Aug 09 '19
!fplbot wilson vs king
1
u/nirzhor_cyclonite Aug 09 '19
I'm new here, can someone tell me how to run the command? From where do I run it? Search box?
1
u/Preacheer Aug 09 '19
!fplbot Aubameyang vs Newcastle
1
u/matt1234w Aug 09 '19
!fplbot barkely vs. perez 5
1
u/Borna09 Aug 09 '19
!fplbot Fraser vs. Lucas Moura 5
1
u/asgar0r 10 Aug 09 '19
!fplbot Kane vs Aston Villa
!fplbot Aubameyang vs Newcastle
1
u/reddiablo_91 1 Aug 10 '19
!fplbot alexander-arnold vs robertson 19
1
u/1anastazie 3 Aug 12 '19
!fplbot Sterling vs Bournemouth
1
u/isaacturon14 20 Aug 14 '19
!fplbot Mina vs. Digne 10
1
u/Mewtedly 6 Aug 15 '19
!fplbot sterling vs spurs 10
1
u/10StrokesOfKane redditor for <1 week Aug 16 '19
!fplbot Aubameyang vs Burnley 5
1
u/arpitj23 4 Aug 17 '19
Aubameyang vs Burnley
1
u/motiveunclear 8 Aug 18 '19
!fplbot Kane vs Newcastle
1
u/xhakaal redditor for <30 days Aug 18 '19
!fplbot Lacazette vs. Wilson 5
1
u/k2oosh 5 Aug 18 '19
!fplbot Son vs Newcastle 5
1
u/InternalWalrus 5 Aug 18 '19
!fplbot <Martial> vs. <Pulisic>
1
u/RomeMe1122 65 Aug 19 '19
!fplbot Vardy vs Wilson
1
u/angussavage Aug 19 '19
!fplbot martial vs. Rashford 22
1
u/[deleted] Aug 20 '19
!fplbot sterling vs bournemouth
1
u/iMMoss13 Aug 21 '19
!fplbot Kane vs. Newcastle
1
u/SeeImGood Aug 23 '19
!fplbot Kane vs Sterling
1
u/SeeImGood Aug 23 '19
!fplbot Sterling vs Bournemouth
1
u/TwelfthPine Aug 23 '19
Barnes or Jota
1
u/iMMoss13 Aug 24 '19
!fplbot salah vs. Arsenal
1
u/freakingfreak77 Aug 25 '19
!fplbot sterling vs brighton 10
1
u/freakingfreak77 Aug 25 '19
!fplbot salah vs burnley
1
u/freakingfreak77 Aug 25 '19
!fplbot De Bruyne vs burnley
1
u/isaacturon14 20 Aug 26 '19
!fplbot Kane vs. Arsenal 5
1
u/isaacturon14 20 Aug 26 '19
!fplbot Son vs. Arsenal 5
1
u/TheRinzler1992 1 Aug 26 '19
!fpl bot salah vs burnley
1
u/charbocca Aug 26 '19
!fplbot Wilson vs Abraham 3
1
u/Ragnarly-Dude 1 Aug 27 '19
!fplbot Rashford vs. southampton 5
1
u/Ragnarly-Dude 1 Aug 27 '19
!fplbot Martial vs. southampton 5
1
u/iMMoss13 Aug 27 '19
!fplbot De Bruyne vs. Brighton
1
u/iMMoss13 Aug 27 '19
!fplbot mane vs. Burnley
1
u/carterish 8 Aug 30 '19
!fplbot Cantwell vs. Lanzini 3
1
u/PokeCapt 67 Sep 01 '19
!fplbot Digne vs Wolves
1
u/tanmaykalla95 Sep 03 '19
!fplbot Mane vs Newcastle
1
u/tanmaykalla95 Sep 03 '19
!fplbot Kane vs Crystalpalace
1
u/MosF94 107 Sep 03 '19
!fplbot Salah vs Newcastle
1
u/nttin710 Sep 05 '19
!fplbot Ashley Barnes vs. Brighton 5
1
u/[deleted] Sep 08 '19
Is fplbot down?
1
u/thestifled1 54 Sep 11 '19
!fplbot barnes vs. Brighton
1
u/RomeMe1122 65 Sep 14 '19
!fplbot Kevin De Bruyne vs Watford 5
1
u/RomeMe1122 65 Sep 14 '19
!fplbot Chris Wood vs Brighton
1
u/RomeMe1122 65 Sep 14 '19
!fplbot Callum Wilson vs Southampton
1
u/ReallyIsGreatBanter 2 Sep 14 '19
!fplbot Salah vs Newcastle
1
u/ReallyIsGreatBanter 2 Sep 14 '19
!fplbot mane vs newcastle
1
u/Looks_Good_In_Hats Sep 20 '19
!fplbot van Aanholt vs. Wolves 5
1
u/Looks_Good_In_Hats Sep 20 '19
!fplbot van aanholt vs. wolves 5
1
u/Looks_Good_In_Hats Sep 20 '19
!fplbot aanholt vs. wolves
1
u/Lets_Go_Lightning 1 Sep 26 '19
!fplbot Kane vs Southampton
1
u/El-Sebastian-Cruz 6 Sep 28 '19
!fplbot jimenez vs watford
1
u/El-Sebastian-Cruz 6 Sep 28 '19
!fplbot Sterling vs Everton
1
u/RomeMe1122 65 Sep 29 '19
!fplbot Wood vs Everton
1
u/Xugua99 redditor for <30 days Sep 29 '19
!fplbot Salah vs Leicester City
1
u/ReaganRewop 4 Sep 30 '19
!fplbot jamie vardy vs liverpool
1
u/Bneil4204 Feb 10 '23
!fplbot Ødegaard vs. Mahrez
1
u/notnotaschizo 19 Mar 31 '24
!fplbot heung-min son vs. Maddison 5
1
u/Any-Examination-2932 redditor for <30 days Jul 18 '24
!fplbot Isak vs Southampton 5
1
u/Hairy-Dentist9377 Aug 05 '24
!fplbot son vs. Leicester