A Lemmy Bot that create and maintains NBA Game threads, Post Game threads and Daily Game Index threads.
The Bot uses
nba_api
- An API Client package to access the APIs for NBA.compythorhead
- A python library for interacting with Lemmy
DISCLAIMER: THIS CODE IS STILL IN DEVELOPMENT, USE AT YOUR OWN RISK!
The following parameters are needed for the bot to run:
- domain (or environment var INSTANCE_URL): Base endpoint to the Lemmy instance, for example 'https://lemmy.world' (note - https, and no '/' at the end)
- username (or environment var BOT_USERNAME):The Bot's username
- password (or environment var BOT_PASSWORD):The Bot's password
- community (or environment var BOT_COMMUNITY): Lemmy community name, so this is the full community URL {domain}/c/{community}
- admin_id (or environment var BOT_ADMIN_ID): A Lemmy User ID, that will receive a Direct Message from the BOT when it's failed in unexpected ways... A hacky way to find this ID is by trying to DM the user, and looking at the URL which would be in the shape of https://lemmy.world/create_private_message/
The following parameters are optional:
- sleep (or environment var BOT_SLEEP_SECS): Sleep duration between Bot cycles, defaults to 60 seconds
- team_name (or environment var BOT_TEAM_NAME): A team abbreviation (e.g. BOS) or full name (Boston Celtics). If set, the Bot will only create posts for this specific team, and will not create Daily Index posts (as they will only have a single line)
git clone https://github.com/GitBarns/lemmy_nba_gameday_bot.git
cd lemmy_nba_gameday_bot
python3 ./nbagamebot.py --domain 'https://lemmy.world' --username '<Bot User name or Email>' --password '<Bot Password>' --community 'nba' --admin_id <LEMMY USER ID>
Logs would be created in the Logs folder
Note: This above is for testing purposes. You will need to run the Bot as a background process, using nohup or tmux or byobu or something similar
Encounter a bug, report a bug.
Creating a Bot is identical to creating a user on your Lemmy Instance but please make sure you mark your Bot as such in its settings page
Optionally: Make the Bot a Mod if Daily Index Posts are needed so it can Feature these posts (pin them to the top of the community)
Well, you will need to self-host the bot. There are quite a few free options for hosting a small python project such as this. One potential solution is to open a Google Cloud Account and use their free tier compute instance, which should be enough,
Want to contribute? Make a pull request. Contact @GitBarns with any questions.
Any league where a stable python API client exist should be possible but most likely not as part of this library. Please feel free to fork and create your own versions!