Slack bot to play/queue Spotify
Used&Tested daily in our office with a simple setup. Install on a box connected to speakers and enjoy.
Create a file called slackbot_settings.py
with the following contents
# Slackbot settings
API_TOKEN = '<token>'
# Force bot to only work on a single channel
FIXED_CHANNEL = 'music'
# Spotify settings
SPOTIFY_USERNAME = '<username>'
SPOTIFY_PASSWORD = '<password>'
SPOTIFY_MARKET = 'NL'
# Folder with the slack commands
PLUGINS = ['plugins']
Install PIP package for python (lins05/slackbot)
sudo apt-get install python-pip
sudo pip install -r requirements
First you need to get the slack api token for your bot. You have two options:
Then you need to configure the API_TOKEN
in the python module slackbot_settings.py
.
Follow pyspotify installation on https://pyspotify.mopidy.com/en/latest/installation/
or in short:
wget -q -O - https://apt.mopidy.com/mopidy.gpg | sudo apt-key add -
sudo wget -q -O /etc/apt/sources.list.d/mopidy.list https://apt.mopidy.com/jessie.list
sudo apt-get update
sudo apt-get install python-spotify
Get a binary spotify application key and store it in the main folder: https://devaccount.spotify.com/my-account/keys/
Finally install the correct audio driver:
sudo apt-get install python-alsaaudio
Follow instructions for Ubuntu and read the source websites for the spotify python library.
The audio driver for OSX is PyAudio:
pip install pyaudio
OSX should be detected and use this library, although this is untested
To play a song
@slackify: play <query>
To pause or continue
@slackify: pause
@slackify: play
To stop playing
@slackify: stop
@slackify: search <query>
To play a song from a search result use:
@slackify: play <search_number>
Search results are stored per user, you can only play from your own search result
@slackify: queue <query>
Or using the search result
@slackify: queue <search_number>
Skip your song in the queue
@slackify: next
Remove a song from the queue
@slackify: remove <number>
When a song is playing you can query related artists and their top songs
@slackify: related
Now you can play/queue the result like a normal search
By default the player will continue playing songs you queued before (random mode). You can however toggle to related mode. Now the player will pick a random related artist and play one of its top tracks.
To view the current mode
@slackify: mode
Change the mode:
@slackify: mode related
@slackify: mode random
To show or hide album art when a new song starts
@slackify: hide album art
@slackify: show album art
A simple command overview
@slackify: help
Sometimes a recently joined user can't use the bot, a reconnect can solve this issue.
@slackify: reconnect
@slackify: volume <up/down> <number>
: Change the volume@slackify: vote <queue_number>
: Remove a song someone queued@slackify: vote next
: Vote to skip current song@slackify: admin add <user>
: Add user as admin@slackify: admin remove <user>
: Remove user as admin