Code Monkey home page Code Monkey logo

nhl-bot's Introduction

Adam's GitHub stats

Top Langs

nhl-bot's People

Contributors

admajonse avatar

Stargazers

 avatar

Watchers

 avatar  avatar

nhl-bot's Issues

Handle updates to goal events

Goals aren't always posted with full details right away. Sometimes you just get the goal scorer and then the event is updated to include the assists after the fact. We need some way to detect when an event has been updated.

One way to handle this would be to post the goal with the goal scorer initially and then reply to the tweet with the full goal details (IE: who got the assists, etc).

This would require an update to the way we handle events - currently we only process new events, once an event has shown up and been processed, it's ignored. Maybe we could cache a copy of the last JSON data, compare previous records to the updated data and determine whether any previously processed events have been updated?

Tweet all attempts during a shootout

Shootout attempts are just treated as shot or goal events, but they have their period set to SHOOTOUT. We should log all events where period is set to the shootout. These should be special events and post the score of the shootout so far if possible.

Penalty description is sometimes just the severity

Sometimes we have tweets like this:
https://twitter.com/avalanche_bot/status/1516969975235371012

Josh Manson
2 minute minor for minor

This likely means that the secondaryType is initially just populated with the severity and then the actual penalty is added after the fact. We should verify that there is an actual penalty call prior to tweeting. If there's not, we can delay the tweet, similar to the way that we delay when the penalty taker is not present.

Late start times cause games to be missed

When we run in a container, the system uses UTC time (midnight UTC corresponds to 8:00 PM eastern). This means that when we start the container and query the date to determine if there's a game today, we may actually be querying the wrong date.

The NHL API uses UTC for time stamps in their game data, however, the "date" field in a schedule query considers games that start after midnight UTC to still be part of the previous day.

I think the simplest way to deal with this is to simply apply an offset when checking for games on a given date. The latest we ever see a game start is around 10:30 PM EST (or 3:30 UTC on the next day). To be safe, we could simply convert the UTC time to EST prior to getting the date.

Handle line score events

Some game events (ie: pulling the goalie) aren't displayed as events in the allPlays list, but they do appear in the line score. For example, whether or not a goalie is pulled is a boolean in the line score. We should add some sort of handler that is triggered when this value in the line score changes.

Break dependency between printer and tweet classes

The printer doesn't really need to be responsible for tweeting. Lets just have it return strings with tweet text and we can tweet from somewhere else, thereby removing the dependency on tweeter.py.

Add GitHub workflow

We should be using GitHub workflows to automatically build and run the docker container and ensure that the bot is functioning correctly. The workflow should run any unit tests (once I get around to writing them). Change requests that aren't functional should be rejected.

Remove time-based checking from the record filter

Currently we only process events that have not been processed previously (IE: the event ID is greater than the last event that was processed). There is also a time-based check (currently set to three minutes, but I've been experimenting with this a bit). This time-based check is mainly intended to reduce the amount of spam created when we start the bot mid-game. In this case, last_event is initialized to 0 and so we'll process every event that has occurred in the game so far. A better way to handle this would be to silently process all previous events without tweeting and set last_event to the latest event and then start regular processing from there. This would allow us to remove the time-based check completely and only process new events.

Neutral site games have the wrong arena listed

This is pretty rare obviously, but when a game is played at some venue other than the home team's arena, we post the wrong location in the game day and period start/finish tweets. Right now we're just retrieving the venue data from the home team's info record, but maybe there's some sort of game data that we can pull from instead? Needs a bit of investigation of the API, but this should presumably be a quick fix.

The shootout complete event is unhandled

Not sure if they've added this to the API this season or it was just rare enough to miss. There's an event that occurs when a shootout ends called Shootout Complete. We should handle this (even if just to throw it away). Right now it's raising an exception.

Not handling all possible game events

We don't necessarily need to post a tweet during all game events, but the bot should be aware of them and capable of handling them if the printer object defines behaiviour for this event.

The current set of events was taken from a single game. This game did not include overtime or a shootout. I'm pretty sure there will be some special event types that only occur during OT/shootout (ie: a shootout attempt). The game also didn't feature a penalty shot. There are probably other events that haven't occurred to me here.

We need to determine the full set of possible events and handle all of them in some way (even if they're just silently ignored, or logged without a tweet).

The bot misses a day when a game ends after midnight EST

When the game ends, it is supposed to sleep until the following day at noon. This mostly works because most games end on the same date that they started, but for late games (ie: 9:30 - 10:30 PM EST start time), the game will sometimes end after midnight. When this happens, the bot will sleep until the after that, which could mean that we miss a game. It's pretty unlikely that you're going to have a game that ends after midnight and a game the next day, but we should make sure this works just to be safe. The simplest solution would be to record the game start time and wait until midnight on the day following the start time (rather than the end time as we do now).

Shootout goals are registering as goalscorer changes

The bot seems to think that all the shootout attempts are the same goal and keeps reporting new goals as goalscorer changes (ie: "The goal is now being awarded to" replies). This is likely related to the new method of identifying goal events (some sort of key that uses the period and time of the goal) - all goals in the shootout likely have the same ID.

We need a way to distinguish the goals in a shootout and then they should start to report correctly again.

Use `diffPatch` to reduce response data size

The NHL API provides the ability to only return updates to the feed that have occurred after a give time. This is a good way to stop repeatedly retrieving and processing events that have already been dealt with. We should update the live feed data request to use this instead of the base live feed.

https://statsapi.web.nhl.com/api/v1/game/ID/feed/live/diffPatch?startTimecode=yyyymmdd_hhmmss

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.