dandroid126 / lemmy-nhl-gdt-bot Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU General Public License v3.0
License: GNU General Public License v3.0
Each interval (possibly 1 minute?) data needs to be polled and relevant games need to be updated
Currently both DB queries are made and the feed live API is hit for games that aren't within their window to have a post made. Optimize this. This information can be determined from the schedule API only, and the DB queries and feed live API can be skipped.
Could be useful for catching up after missing a few days of hockey.
Blocked by this issue: LemmyNet/lemmy-ui#1758
This isn't a blocking issue, but it would be nice to have it fixed: LemmyNet/lemmy-ui#2082
Example:
PT | MT | CT | ET | AT |
---|---|---|---|---|
07:00PM | 08:00PM | 09:00PM | 10:00PM | 11:00PM |
Need to create a Dockerfile that copies all src files and runs main.py. The .env file will be mounted as a volume.
Currently there will always be three periods in the score table, even if there are only 2 periods or an OT period or SO. This needs to be dynamic so when games go to OT and SO it can be viewed. Also it might crash if there are fewer than 3 periods. ๐ฌ
When new columns need to be added to the DB, this currently must be done manually (yuck!). There should be a db version constant that gets updated every time the db changes. And when this version changes, the db upgrade code should be run. This will probably need a table to track the db version, so this should probably be done sooner rather than later.
Since the big NHL API update during the preseason, the goalie that was in net is no longer easily accessible. Either figure out a way to get this data, or remove the column.
Currently, with single-post setup (one game per post), the software will not create a thread for the game until 1 hour before puck drop. I suggest making this configurable.
Personally, I'd generally want the post to be created early in the day at a set time, such as 8 a.m. local time. I might be in the minority on this, though.
However, an easier option in the interim would be a configurable number of hours, such as 6 hours before puck drop.
Add hosting instructions and such
Most front-ends have this fixed now.
Example:
Period | Time | Team | Type | Min | Description |
---|---|---|---|---|---|
3rd | 09:05 | VGK | Minor | 2 | Jack Eichel Roughing against Vincent Desharnais |
3rd | 07:57 | EDM | Minor | 4 | Warren Foegele High-sticking - double minor against Ben Hutton |
2nd | 19:36 | VGK | Major | 5 | Keegan Kolesar Boarding against Mattias Ekholm served by William Carrier |
2nd | 19:36 | VGK | Game Misconduct | 10 | Keegan Kolesar Game Misconduct |
2nd | 13:33 | EDM | Minor | 2 | Mattias Janmark High-sticking against Jack Eichel |
2nd | 12:49 | EDM | Minor | 2 | Philip Broberg Holding against Jack Eichel |
1st | 17:12 | EDM | Minor | 2 | Philip Broberg Holding against Brett Howden |
1st | 14:09 | EDM | Minor | 2 | Kailer Yamamoto Interference against Teddy Blueger |
1st | 09:14 | VGK | Minor | 2 | Nicolas Hague Tripping against Warren Foegele |
1st | 03:52 | EDM | Bench Minor | 2 | Delaying Game - Unsucc. chlg served by Zach Hyman |
1st | 01:10 | VGK | Minor | 2 | Reilly Smith Hooking against Evan Bouchard |
Team object should have team names, team abbreviations, and (possibly) links to team logos or names of team logo emojis that can be rendered as text
Make this configurable in the .env file. Allow the user to set what types of games are their own post and what types of games are comments on the daily post (e.g. preseason and regular season are comment games, postseason are full posts).
The bot shouldn't crash if there is a mistake on the API end. All dictionary accesses should either be in a try/catch or be a safe call. All values in data classes should have default values in case anything fails to be fetched from the API data for whatever reason. The default values should indicate that an error has occurred.
This will prevent all games from getting stuck when one game gets stuck from the unaddressed timeout issue in pythorhead. Also, just in general, I think it would be a good idea to have the games update independently of each other in the event some unforeseen issue holds the main thread up.
Fill all objects with data from the APIv2 (base url: https://api-web.nhle.com/v1).
๐ญ
Example:
Period | Time | Team | Strength | Description |
---|---|---|---|---|
3rd | 02:40 | EDM | Power Play | Connor McDavid (7) Wrist Shot, assists: Evan Bouchard (13) |
2nd | 15:34 | VGK | Even | Nicolas Hague (1) Slap Shot, assists: Jack Eichel (7), Jonathan Marchessault (5) |
2nd | 14:34 | VGK | Power Play | Reilly Smith (1) Batted, assists: Ivan Barbashev (3), William Karlsson (3) |
2nd | 14:05 | VGK | Power Play | Mark Stone (5) Wrist Shot, assists: Jack Eichel (6), Jonathan Marchessault (4) |
1st | 09:56 | EDM | Power Play | Zach Hyman (3) Deflected, assists: Ryan Nugent-Hopkins (9), Evan Bouchard (12) |
1st | 03:52 | VGK | Even | Jack Eichel (6) Wrist Shot, assists: Alec Martinez (2), Jonathan Marchessault (3) |
1st | 03:02 | EDM | Power Play | Connor McDavid (6) Wrist Shot, assists: Ryan Nugent-Hopkins (8), Zach Hyman (8) |
Because the schedule is based on UTC time, a span of two days will need to be used. This means with the current implementation, some games will be updating for 40 hours after they complete. This is excessive.
As a starting point, have games stop updating an hour after they end.
MOAR
It only seems to work for comments, not posts.
This should only build, not push the container image.
Right now OT2 shows as a shootout. And OT3 probably will crash the bot.
It looks weird right now.
Trying to run this on docker under Debian Linux for the Caps community. I actually had it working once, it posted a GDT, but I deleted the post because I had it set to do comments instead of posts for the GDTs. Since then, no luck with either setting. Here's what's happening when I run it:
user@system:~/lemmy-nhl-gdt-bot$ sudo docker run --rm --name lemmy-nhl-gdt-bot -v ./.env:/app/.env -v ./out:/app/out ghcr.io/dandroid126/lemmy-nhl-gdt-bot:main
Apr 13 11:04:31 nhl-gameday-bot [1]: [INFO] [EnvironmentUtil] Environment loaded
Apr 13 11:04:31 nhl-gameday-bot [1]: [INFO] [DbManager] init(): Connection to SQLite DB successful
Apr 13 11:04:31 nhl-gameday-bot [1]: [INFO] [DbManager] get_db_schema_version(): executing: SELECT version FROM db_schema WHERE rowid = '0'
Apr 13 11:04:32 nhl-gameday-bot [1]: [DEBUG] Starting new HTTPS connection (1): lemmy.world:443
Apr 13 11:04:32 nhl-gameday-bot [1]: [DEBUG] https://lemmy.world:443 "GET /nodeinfo/2.0.json HTTP/1.1" 200 None
Apr 13 11:04:32 nhl-gameday-bot [1]: [INFO] Connected succesfully to Lemmy v0.19.3 instance https://lemmy.world
Apr 13 11:04:32 nhl-gameday-bot [1]: [INFO] Requesting API Request.POST /user/login
Apr 13 11:04:32 nhl-gameday-bot [1]: [DEBUG] Starting new HTTPS connection (1): lemmy.world:443
Apr 13 11:04:34 nhl-gameday-bot [1]: [DEBUG] https://lemmy.world:443 "POST /api/v3/user/login HTTP/1.1" 200 None
Apr 13 11:04:34 nhl-gameday-bot [1]: [INFO] Requesting API Request.GET /community
Apr 13 11:04:34 nhl-gameday-bot [1]: [DEBUG] Starting new HTTPS connection (1): lemmy.world:443
Apr 13 11:04:34 nhl-gameday-bot [1]: [DEBUG] https://lemmy.world:443 "GET /api/v3/community?name=caps%40lemmy.world HTTP/1.1" 200 None
Apr 13 11:05:04 nhl-gameday-bot [1]: [INFO] [nhl_api_client.py] get_schedule(): url: https://api-web.nhle.com/v1/schedule/2024-04-12
Apr 13 11:05:04 nhl-gameday-bot [1]: [DEBUG] Starting new HTTPS connection (1): api-web.nhle.com:443
Apr 13 11:05:04 nhl-gameday-bot [1]: [DEBUG] https://api-web.nhle.com:443 "GET /v1/schedule/2024-04-12 HTTP/1.1" 200 None
Apr 13 11:05:34 nhl-gameday-bot [1]: [INFO] [nhl_api_client.py] get_schedule(): url: https://api-web.nhle.com/v1/schedule/2024-04-12
Apr 13 11:05:34 nhl-gameday-bot [1]: [DEBUG] Starting new HTTPS connection (1): api-web.nhle.com:443
Apr 13 11:05:34 nhl-gameday-bot [1]: [DEBUG] https://api-web.nhle.com:443 "GET /v1/schedule/2024-04-12 HTTP/1.1" 200 None
I.e., it just keeps rereading the schedule. I can go to that URL and get the schedule, so I'm not sure why it's struggling.
I tried killing it, removing the image, deleting everything in out/, and restarting, and it's not helping.
.env file:
BOT_NAME=xyz
PASSWORD=***
LEMMY_INSTANCE=lemmy.world
COMMUNITY_NAME=[email protected]
COMMENT_POST_TYPES=
GDT_POST_TYPES=PRESEASON,REGULAR,POSTSEASON,ALLSTAR
TEAMS=WSH
I'd appreciate any suggestions!
This post will be stickied each day so GDTs don't need to be stickied.
Every few hours the systemd service restarts. Need to enhance logging to include stdout in the log files to figure out why it is crashing. Need to fail gracefully when an issue occurs.
Also need to tee logs to stdout/stderr, as systemd and podman won't get them otherwise.
Currently no one knows what to put in the .env file without looking at the code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.