A Matrix bot written in Go.
- Matrix bot functionality
- Gotify notification forwarding
- Wakapi report generation.
- Umami report generation.
- RSS integration.
- End-to-end encryption support
- Session persistence
- Go 1.26+ (for building from source)
- Docker (optional, for containerized deployment)
- Nix (optional, for reproducible builds)
Create a compose.yml file:
services:
mytrix:
image: fovir/mytrix:latest
container_name: mytrix
volumes:
- ./mytrix:/data
environment:
- MYTRIX_LOG_LEVEL=INFO
- MYTRIX_HOMESERVER=https://matrix.example.com
- MYTRIX_ROOM_ID=!roomid:matrix.example.com
- MYTRIX_USER_ADMIN_ID=@admin:matrix.example.com
- MYTRIX_BOT_USERNAME=bot@example.com
- MYTRIX_BOT_PASSWORD=your-bot-password
- MYTRIX_BOT_RECOVERY_KEY=your-recovery-key
- MYTRIX_BOT_PICKLE_KEY=random-32-byte-stringThen start the service:
docker-compose up -dAll configuration is done via environment variables.
| Variable | Description | Default |
|---|---|---|
MYTRIX_LOG_LEVEL |
Logging level (DEBUG, INFO, WARN, ERROR) | INFO |
MYTRIX_HOMESERVER |
Matrix homeserver URL | (required) |
MYTRIX_ROOM_ID |
Matrix room ID | (required) |
MYTRIX_DATA_DIR |
Data directory for storing sessions | data |
MYTRIX_TIMEOUT |
HTTP request timeout in seconds | 10 |
MYTRIX_TZ |
Timezone | time.Local |
| Variable | Description | Default |
|---|---|---|
MYTRIX_USER_ADMIN_ID |
Determine who can invite the bot | (required) |
MYTRIX_USER_FORMAT |
The template of listing users | see internal/config/user.go |
| Variable | Description | Default |
|---|---|---|
MYTRIX_DB_PATH |
Path to SQLite database. | sqlite.db |
MYTRIX_DB_BUSY_TIMEOUT |
Timeout when db is busy (in ms) | 5000 |
| Variable | Description | Example |
|---|---|---|
MYTRIX_BOT_USERNAME |
Matrix username of the bot account | mytrix |
MYTRIX_BOT_PASSWORD |
Password for the bot account | 123456 |
MYTRIX_BOT_RECOVERY_KEY |
Encryption recovery key | abcd efgh ijkl |
MYTRIX_BOT_PICKLE_KEY |
Key for encrypting crypto storage | random-32-byte-string |
| Variable | Description | Default |
|---|---|---|
MYTRIX_MSG_ALLOW_MARKDOWN |
Allow Markdown in message contents | true |
MYTRIX_MSG_ALLOW_HTML |
Allow HTML in message contents | false |
MYTRIX_MSG_DEFAULT_MAX_PDU_SIZE |
Default max PDU size | 65535 |
| Variable | Description | Default |
|---|---|---|
MYTRIX_GOTIFY_ENABLED |
Enable Gotify forwarding | false |
MYTRIX_GOTIFY_SERVER |
Gotify server URL (no scheme) | required if MYTRIX_GOTIFY_ENABLED=true |
MYTRIX_GOTIFY_TOKEN |
Gotify API token | required if MYTRIX_GOTIFY_ENABLED=true |
MYTRIX_GOTIFY_FORMAT |
Gotify message format (support Markdown) | see internal/config/gotify.go |
| Variable | Description | Default |
|---|---|---|
MYTRIX_WAKAPI_ENABLED |
Enable Wakapi integration | false |
MYTRIX_WAKAPI_SERVER |
Wakapi server (no scheme) | required if MYTRIX_WAKAPI_ENABLED=true |
MYTRIX_WAKAPI_API_KEY |
API key to access Wakapi server | required if MYTRIX_WAKAPI_ENABLED=true |
MYTRIX_WAKAPI_USER_ID |
User ID of Wakapi user | current |
MYTRIX_WAKAPI_DAILY_REPORT_CRON |
Time to send daily report | 0 9 * * * |
MYTRIX_WAKAPI_WEEKLY_REPORT_CRON |
Time to send weekly report | 0 9 * * 1 |
MYTRIX_WAKAPI_MONTHLY_REPORT_CRON |
Time to send monthly report | 0 9 1 * * |
MYTRIX_WAKAPI_YEARLY_REPORT_CRON |
Time to send yearly report | 0 9 1 1 * |
MYTRIX_WAKAPI_LANG_FORMAT |
Template of language format | see internal/config/wakapi.go |
MYTRIX_WAKAPI_DATA_FORMAT |
Template of Wakapi data format | see internal/config/wakapi.go |
Tip: To disable reports, the cron can be set to
0 0 31 2 *so it will not be triggered.
| Variable | Description | Default |
|---|---|---|
MYTRIX_UMAMI_ENABLED |
Enable Umami integration | false |
MYTRIX_UMAMI_SERVER |
Server of Umami | required if MYTRIX_UMAMI_ENABLED=true |
MYTRIX_UMAMI_USERNAME |
Umami username | required if MYTRIX_UMAMI_ENABLED=true |
MYTRIX_UMAMI_PASSWORD |
Password of Umami user | required if MYTRIX_UMAMI_ENABLED=true |
MYTRIX_UMAMI_DEFAULT_INTERVAL |
Default query interval when no argument passed to Umami command | daily |
MYTRIX_UMAMI_FORMAT |
Template of report format | see internal/config/umami.go |
MYTRIX_UMAMI_DAILY_REPORT_CRON |
Time to send daily report | 0 9 * * * |
MYTRIX_UMAMI_WEEKLY_REPORT_CRON |
Time to send weekly report | 0 9 * * 1 |
MYTRIX_UMAMI_MONTHLY_REPORT_CRON |
Time to send monthly report | 0 9 1 * * |
MYTRIX_UMAMI_YEARLY_REPORT_CRON |
Time to send yearly report | 0 9 1 1 * |
Tip: To disable reports, the cron can be set to
0 0 31 2 *so it will not be triggered.
| Variable | Description | Default |
|---|---|---|
MYTRIX_RSS_ENABLED |
Enable RSS integration | false |
MYTRIX_RSS_FEED_FORMAT |
Template of RSS feeds | see internal/config/rss.go |
MYTRIX_RSS_ITEM_FORMAT |
Template of RSS items | see internal/config/rss.go |
MYTRIX_RSS_CRON |
Interval of fetching RSS feeds | 0 * * * * |
MYTRIX_RSS_UPDATE_AFTER_ADD |
Whether to update feeds after adding one | true |
MYTRIX_RSS_DESCRIPTION_MAX_LENGTH |
Max length of RSS description | 128 |
-
Ping-pong
!ping -
Current version
!version
!umami <interval>Available intervals:
dailyweeklymonthlyyearly
If the interval is not provided, it will fall back to the default interval defined in environment variables.
!wakapi <interval>Available intervals:
todayyesterdayweeklymonthlyyearly7d(Last 7 days)30d(Last 30 days)6m(Last 6 months)12m(Last 12 months)1y(Last 1 year)all(All time)
If the interval is not provided, it will fall back to the default interval defined in environment variables.
-
Add an RSS feed:
!rss add <url1> <url2> -
Update all RSS feeds manually:
!rss update -
List all RSS feeds:
!rss list -
Delete an RSS feed:
!rss delete <id1> <id2> -
Export RSS feeds:
!rss export -
Show help information:
!rss help
- Clone and enter the repository:
git clone https://github.com/Fovir-GitHub/mytrix.git
cd mytrix- Allow
direnv:
direnv allow- Start the server using
just:
just runmautrix/go: A Golang Matrix framework.caarlos0/env: A simple, zero-dependencies library to parse environment variables into structs- Blog by Dominik Chrástecký: Tutorial for this project.
gorilla/websocket: A fast, well-tested and widely used WebSocket implementation for Go.robfig/cron: A cron library for gommcdole/gofeed: Parse RSS, Atom and JSON feeds in Go