A Matrix bot written in Rust. It shows the weekly lunch menu for Mensa Furtwangen (HFU) and monitors websites for changes, sending a notification whenever a tracked value updates.
- Mensa menu — fetches the current week's menu from swfr.de; show today, a specific day, or the full week
- Website alerts — monitor any element on any page; get notified when its text, HTML, or any attribute changes
- Access control — admin users (set via env) plus a mutable allow-list
- Works in DMs and group rooms — no prefix needed in DMs; prefix with the bot name in group rooms
- Auto-join — accepts room invites automatically
- Persistent session — login is saved to disk; no new device created on redeploy
- E2EE — end-to-end encryption via matrix-sdk
Copy .env.example to .env and fill in your values:
MATRIX_HOMESERVER=https://matrix.example.com
MATRIX_USERNAME=@bot:example.com
MATRIX_PASSWORD=your-password
# Optional — defaults to the local part of MATRIX_USERNAME
BOT_NAME=bot
# Comma-separated list of Matrix IDs that always have full access
ADMIN_USERS=@you:example.com,@other:example.com
# Template for change notifications — all placeholders are optional
ALERT_TEMPLATE=Alert {name} changed\n\nOld: {old}\nNew: {new}
# Log level
RUST_LOG=info,matrix_sdk_crypto=errorTemplate placeholders: {name}, {url}, {old}, {new}, {css}, {property}
- Docker + Docker Compose
- Git
-
Clone the repository:
git clone https://github.com/DMeurer/Matrix-Bot.git /opt/matrix-bot cd /opt/matrix-bot -
Create and fill in your
.env:cp .env.example .env $EDITOR .env -
Start the bot:
docker compose up -d
The bot logs in, saves its session to ./session/, and starts listening. The session/ directory is bind-mounted so it survives container rebuilds.
A cron job polls for new commits every minute and rebuilds automatically with zero downtime.
-
Make sure the current user can run
dockerwithoutsudo:sudo usermod -aG docker $USER newgrp docker # activates the group without logging out
-
Add to crontab (
crontab -e):* * * * * sh /opt/matrix-bot/deployment/cronjob.sh
When a new commit lands on main, the job pulls the changes and runs docker compose up -d --no-deps --build. Concurrent runs are prevented by a lockfile. Logs are written to deployment/logs/cronjob.log.
git pull
docker compose up -d --buildcp .env.example .env # fill in credentials
cargo runcargo test