- Go 98.3%
- Dockerfile 1.7%
Same features on mautrix-go instead of telego: !to_voice and !to_circle (! or / prefix), command in a caption or as a reply to a file, YouTube and Instagram downloads by yt-dlp. Voice messages keep their waveform flag, circles become square cropped videos, albums come back as a message sequence with the caption after them. The bot auto-accepts invitations and only works in unencrypted rooms. MATRIX_HOMESERVER defaults to https://chat.blya.by; the bot logs in with MATRIX_TOKEN or MATRIX_PASSWORD and syncs via /sync. |
||
|---|---|---|
| .forgejo/workflows | ||
| cmd/util-bot | ||
| internal | ||
| .dockerignore | ||
| Dockerfile | ||
| go.mod | ||
| go.sum | ||
| README.md | ||
util-bot
Matrix bot that converts music and video files into voice messages and square cropped videos, and downloads YouTube and Instagram links.
| Command | Send next | Result |
|---|---|---|
!to_voice |
any audio or video file | voice message (OGG/Opus) |
!to_circle |
a video | square cropped video, at most 640px, first minute only |
Commands also work with a / prefix (/to_voice). You can put the command in the file's
caption, or reply to a file with it.
Send a message with a link in it and the bot downloads it and sends it back, video at up to 720p.
Anything that doesn't fit in MAX_UPLOAD_MB is refused instead of downloaded.
| Site | Links | Result |
|---|---|---|
| YouTube | watch, youtu.be, Shorts, live, embed |
the video, with its title sent after it |
posts, reels, /tv/, and the /<user>/reel/<code> form |
the video or photo, with the post text after it; a post holding several items comes back as several messages |
Instagram serves reels and public photo posts without logging in, which is all the bot asks for. Private accounts and stories need cookies and aren't supported.
The bot answers room invitations on its own. Note that it has no end-to-end encryption: it only sees unencrypted rooms, so use it there.
Requirements
- Go 1.26+
ffmpegwithlibopusinPATHyt-dlpinPATH
Configuration
| Variable | Required | Description |
|---|---|---|
MATRIX_HOMESERVER |
no | Homeserver the bot works on, default https://chat.blya.by |
MATRIX_USER_ID |
yes | The bot's user ID, e.g. @util-bot:chat.blya.by |
MATRIX_TOKEN |
yes¹ | Access token of the bot account |
MATRIX_PASSWORD |
yes¹ | Password of the bot account, used to log in when MATRIX_TOKEN is unset |
MATRIX_DEVICE_NAME |
no | Device name shown after a password login, default util-bot |
PROXY_URL |
no | socks5://user:pass@host:1080, http://host:3128 or https://…. If unset, HTTPS_PROXY/ALL_PROXY are used |
MAX_FILE_MB |
no | Max input size, default 50 |
MAX_UPLOAD_MB |
no | Max size the bot sends back, default 50. Caps YouTube downloads and media uploads |
¹ One of the two.
An access token can be taken from Element's "Help & About" dialog or another client session.
With MATRIX_PASSWORD the bot logs in by itself and starts syncing; the resulting token is
not saved, so it will log in again on every start (creating a new device each time, unless
the homeserver reuses device IDs).
Run
export MATRIX_USER_ID=@util-bot:chat.blya.by
export MATRIX_TOKEN=...
go run ./cmd/util-bot
PROXY_URL is passed to yt-dlp as well, so YouTube downloads take the same route as the bot.
Docker
docker build -t util-bot .
docker run --rm -e MATRIX_USER_ID=@util-bot:chat.blya.by -e MATRIX_TOKEN=... util-bot