Hockey Twitter Bot – Open Sourced
Today, I finally uploaded the code that runs @NJDevilsGameBot to my Github account.
A few years back, when I got my first Raspberry Pi and learned that the NHL had an API (although no official documentation exists, the current community driven documentation can be found here), I decided to pick up the basics of Python and build something. I ended up putting together a python script that would use the NHL API schedule endpoint to watch for changes in score of New Jersey Devils games and then trigger red beacon lights and the goal song through my receiver. The code was messy and the setup was too unique so I never published it anywhere.
A few weeks ago I decided I want to take some of the foundations built in the aforementioned code, advance my Python skills a bit and Hockey Twitter Bot was born. At its core, the bot is a python script that parses the NHL Schedule & Live Feed API endpoints to gather relevant game events and tweet them to the game bot Twitter account. Some more information (such as events that are parsed and tweeted) and other technical details can be found in the README of the Github repository.
The code is very much a work in progress and considering my Python skills are far mediocre at best, the code will always be. To be honest, the only reason I put the code onto Github is because I am hoping that people that are more proficient in Python than me find it and send me pull requests to fix bugs, remove redundant code or just tell me what I am doing wrong and how it can be better.
I have embedded some sample tweets at the bottom of the post as well just to showcase some sample functionality.
PS – if you are a Devils fan & are not following @NJDevilsGameBot – why not?
The three stars for the game are –
⭐️: Drew Stafford (NJD)
⭐️⭐️: Taylor Hall (NJD)
⭐️⭐️⭐️: Claude Giroux (PHI)#NJDvsPHI— NJDevils Game Bot (@NJDevilsGameBot) February 14, 2018
Scoring changes are done the same way
The goal is assisted by Nico Hischier and Will Butcher. #NJDvsPHIhttps://t.co/QwVvJZKBXr
— NJDevils Game Bot (@NJDevilsGameBot) February 14, 2018
The 2nd period of #NJDvsPHI comes to an end.
Devils: 3 (21 shots)
Flyers: 4 (26 shots)— NJDevils Game Bot (@NJDevilsGameBot) February 14, 2018
Tonight's #NJDvsCBJ starting lineup for your New Jersey Devils –
Zajac-Coleman-Noesen
Greene-Vatanen
Kinkaid— NJDevils Game Bot (@NJDevilsGameBot) February 11, 2018