A slackbot for controlling the music in the office.
Local development instructions
- Make sure mysql and redis are installed and running
- Create a mysql database called musicbot
- Clone the repo, create a virtual environment, and run
pip install -r requirements.txt
- Create a
config_local.pyfile, and configure for your local environment. See
config_default.pyfor further instructions setting up your local config.
- Once you have configured everything, run the following commands to provision the database:
python app.py db upgradewill run all migrations and set up the playlist table
python app.py seed_dbwill seed the database with tracks from the spotify playlist referenced in
python app.py runserverto start the server.
- When running locally, you will not actually be able to interact with Slack, so there is a test route set up for trying
out commands. Send POST requests to
localhost:2000/test/<command>?user=<user>, to interact with musicbot.
- About the Poller: There is a separate python script
poller.pythat when running will poll the sonos device at regular intervals to determine if new tracks need to be added to the playlist. Running this script is not necessary for local development, but when running will call
MusicBot.add_random_track()if there are no tracks left to play.
- Tests are in the
tests/folder and are broken into suites according to the classes that they test. Tests use the
SonosMockclass to emulate the Sonos API, so tests will not interfere with the current Sonos playback. Tests that write to the database will cleanup after themselves as well.