mmpychessbot
Matthew Dorner's chess plugin for Mattermost makes it easy to play against your friends and colleagues, but has no built-in machine opponent. This simple service built upon Alex Tzonko's bot and Niklas Fiekas' chess library allows you to add any machine opponent that uses the Universal Chess Interface.
Installation
- Create a system user on any machine that is always on, and has network access to your Mattermost service.
This can be the same server that Mattermost is on. E.g.:
sudo adduser --system --group --shell /bin/bash chessbot
- On the same machine, download and install a UCI chess engine, like Stockfish, to a location that user can access. E.g.:
Ensure you choose a version that works on your CPU. You may need an older Stockfish engine for your system.
wget https://stockfishchess.org/files/stockfish_15_linux_x64_bmi2.zip unzip stockfish_15_linux_x64_bmi2.zip sudo install stockfish_15_linux_x64_bmi2/stockfish_15_x64_bmi2 /usr/local/bin/stockfish
- Switch to your new user:
sudo -u chessbot -i cd
- Install the python dependencies:
pip install -U chess mmpy-bot
- Clone this repo:
git clone https://github.com/Roy-Orbison/mmpychessbot.git cd mmpychessbot/
- Copy the example service conf file and open it for editing:
Change the URL to your Mattermost server's, and copy the team's slug from a URL in its main interface, e.g. the
cp mmpychessbot.conf{.example,} vim mmpychessbot.conf
your-team
inhttps://mattermost.your-domain.example/your-team/channels/town-square
. - In Mattermost's main interface, open the Integrations panel from the ⋮⋮⋮ menu, and add a bot account. It does not require any elevated privileges. Copy the access token it provides you back into the
.conf
file and then save it and close your editor. - If you chose a different username or home directory location in step 1, first make a copy of the example service file (as with the
.conf
example), and edit theUser=
and/or paths to match. exit
the service account's shell. Copy the example or move your customised version of the service file to/usr/local/lib/systemd/system/mmpychessbot.service
- Enable and start the service:
sudo systemctl enable --now mmpychessbot
Play
Start a game with the bot account's username as you would any other team member. If you can't see the bot account's icon to access its user menu, thus the Challenge User to Chess link, create a DM channel with it.
You can “nudge” it into responding by @
-mentioning its username in a game channel.