This is a simple Discord bot that opens the MOPK doors when someone sends the appropriate message in the appropriate channel. It runs in a Raspberry Pi, controlling two relays (one for each door).
On the left side there is 12V power supply. Behind the two relay boards, a step down DC converter provides 5V to the Raspberry Pi through the USB-C port.
The code is based on this excellent tutorial.
The Raspberry Pi runs Ubuntu 22.04 LTS and Docker. The device gets its network from eth0 using DHCP, while wlan0 is set up as an access point, as described here (with WPA2 support). The relays are connected to GPIO pins 23 and 24.
To run the bot:
docker run -d \
--restart=always \
--name mopk-bot \
--device /dev/gpiomem \
-e DISCORD_TOKEN=<the bot token> \
-e DISCORD_GUILD=<the server name> \
-e DISCORD_CHANNEL=<the channel name> \
chazapis/mopk-bot:20240428
First create a .env
file with the following contents:
DISCORD_TOKEN=<the bot token>
DISCORD_GUILD=<the server name>
DISCORD_CHANNEL=<the channel name>
Then run locally with:
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python bot.py