A Matrix bot that rewrites Twitter/X links to xcancel.com.
When a message in a joined room contains a twitter.com, x.com, or fixupx.com link, the bot replies with the same message with those links replaced by xcancel.com equivalents.
All configuration is via environment variables.
| Variable | Flag | Required | Description |
|---|---|---|---|
MATRIX_HOMESERVER |
--homeserver |
Yes | URL of your Matrix homeserver (e.g. https://matrix.org) |
MATRIX_USERNAME |
--username |
Yes | Bot account user ID (e.g. @twitbot:matrix.org) |
MATRIX_PASSWORD |
--password |
Yes | Bot account password |
MATRIX_INVITE_USER |
--invite-user |
No | If set, the bot will automatically accept room invites from this user ID |
REPLY_PREFIX |
--reply-prefix |
No | If set, replies contain only the replaced links preceded by this string (e.g. fixed:). Without it the full message is echoed with links swapped in place. |
MATRIX_HOMESERVER=https://matrix.example.com \
MATRIX_USERNAME=@twitbot:example.com \
MATRIX_PASSWORD=secret \
MATRIX_INVITE_USER=@you:example.com \
REPLY_PREFIX="fixed:" \
cargo run --releaseOr equivalently with flags:
cargo run --release -- \
--homeserver https://matrix.example.com \
--username @twitbot:example.com \
--password secret \
--invite-user @you:example.com \
--reply-prefix "fixed:"Requires Rust 1.80+ (uses LazyLock).
cargo build --releaseImages are published to ghcr.io/neiam/twitbot. Pull and run:
podman run --rm \
-e MATRIX_HOMESERVER=https://matrix.example.com \
-e MATRIX_USERNAME=@twitbot:example.com \
-e MATRIX_PASSWORD=secret \
-e MATRIX_INVITE_USER=@you:example.com \
-e MATRIX_JOIN_ROOM='#room:example.com' \
-e REPLY_PREFIX='fixed:' \
ghcr.io/neiam/twitbot:latestOr with an env file:
podman run --rm --env-file .env ghcr.io/neiam/twitbot:latestTo build locally instead:
podman build -t ghcr.io/neiam/twitbot:latest .A twitbot.container Quadlet unit is included. To install it as a user service:
# Create the env file with your secrets
mkdir -p ~/.config/twitbot
cat > ~/.config/twitbot/env <<EOF
MATRIX_HOMESERVER=https://matrix.example.com
MATRIX_USERNAME=@twitbot:example.com
MATRIX_PASSWORD=secret
MATRIX_INVITE_USER=@you:example.com
MATRIX_JOIN_ROOM=#room:example.com
REPLY_PREFIX=fixed:
EOF
chmod 600 ~/.config/twitbot/env
# Install the unit
cp twitbot.container ~/.config/containers/systemd/
# Reload and start
systemctl --user daemon-reload
systemctl --user enable --now twitbotUser: check out https://twitter.com/user/status/123456
twitbot: check out https://xcancel.com/user/status/123456