2022-07-22 08:42:44 +00:00
|
|
|
# matrix-ops-bot
|
|
|
|
|
|
2022-12-01 16:31:04 +00:00
|
|
|
> a bot for ops in matrix
|
2022-07-22 08:42:44 +00:00
|
|
|
|
2022-12-01 16:31:04 +00:00
|
|
|
This bot catches webhooks and forwards them as messages to matrix rooms.
|
2022-07-22 14:12:14 +00:00
|
|
|
|
2022-12-01 16:31:04 +00:00
|
|
|
Current supported webhooks:
|
|
|
|
|
|
|
|
|
|
* PagerDuty
|
|
|
|
|
* AWS SNS
|
|
|
|
|
* Gitlab
|
2022-07-22 14:12:14 +00:00
|
|
|
|
2022-07-22 12:53:34 +00:00
|
|
|
## Usage
|
|
|
|
|
|
2022-12-01 16:31:04 +00:00
|
|
|
See [config.json.sample](config.json.sample) for a sample config file.
|
|
|
|
|
|
|
|
|
|
Once you have a basic config (leave the routing_keys an empty list), you can easily add new webhooks with
|
|
|
|
|
|
|
|
|
|
```console
|
|
|
|
|
$ poetry run config add-hook --name my-hook-name --hook-type gitlab --room-id '!abcd1234:matrix.org'
|
|
|
|
|
|
|
|
|
|
Hook added successfully
|
|
|
|
|
|
|
|
|
|
Your webhook URL is:
|
|
|
|
|
/hook/vLyPN5mqXnIGE-4o9IKJ3vsOMU1xYEKBW8r4WMvP
|
|
|
|
|
The secret token is:
|
|
|
|
|
6neuYcncR2zaeQiEoawXdu6a4olsfH447tFetfvv
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
Note: Register your bot user manually. This program does not register a new
|
|
|
|
|
user. You must also accept invitations to join the room automatically.
|
2022-07-22 14:12:14 +00:00
|
|
|
|
2022-07-22 12:53:34 +00:00
|
|
|
```
|
|
|
|
|
docker build -t registry.gitlab.com/guardianproject-ops/matrix-ops-bot .
|
2022-07-22 12:05:59 +00:00
|
|
|
|
2022-07-22 12:53:34 +00:00
|
|
|
docker run --rm \
|
|
|
|
|
--name ops-bot \
|
|
|
|
|
--volume /path/to/store:/data \
|
|
|
|
|
--env MATRIX_HOMESERVER=https://matrix.org \
|
|
|
|
|
--env MATRIX_USER_ID=@YOURBOT:matrix.org \
|
|
|
|
|
--env MATRIX_PASSWORD="changeme" \
|
|
|
|
|
--env MATRIX_DEVICE_NAME=my-bot-server \
|
|
|
|
|
--env BOT_ROUTING_KEYS="{\"room1\": \"!XXXX:matrix.org\", \"room2\": \"!YYYYY:matrix.org\"}" \
|
|
|
|
|
--env BOT_BEARER_TOKEN="changeme" \
|
|
|
|
|
registry.gitlab.com/guardianproject-ops/matrix-ops-bot
|
|
|
|
|
```
|
|
|
|
|
|
2022-07-22 14:12:14 +00:00
|
|
|
or docker-compose:
|
|
|
|
|
|
|
|
|
|
```yaml
|
|
|
|
|
version: "3.8"
|
|
|
|
|
services:
|
|
|
|
|
bot:
|
|
|
|
|
image: registry.gitlab.com/guardianproject-ops/matrix-ops-bot:main
|
|
|
|
|
environment:
|
|
|
|
|
MATRIX_HOMESERVER: "https://matrix.org"
|
|
|
|
|
MATRIX_USER_ID: "@YOURBOT:matrix.org"
|
|
|
|
|
MATRIX_PASSWORD: "changeme"
|
|
|
|
|
MATRIX_DEVICE_NAME: "my-bot-server"
|
|
|
|
|
BOT_BEARER_TOKEN: "changeme"
|
|
|
|
|
BOT_ROUTING_KEYS: >
|
|
|
|
|
{"room1": "!XXXX:matrix.org", "room2": "!YYYYY:matrix.org"}
|
|
|
|
|
user: "1000"
|
|
|
|
|
ports:
|
|
|
|
|
- "0.0.0.0:1111:1111"
|
|
|
|
|
volumes:
|
|
|
|
|
- /home/admin/bot/data:/data:rw
|
|
|
|
|
logging:
|
|
|
|
|
driver: "json-file"
|
|
|
|
|
options:
|
|
|
|
|
max-size: "100m"
|
|
|
|
|
max-file: "3"
|
|
|
|
|
```
|
|
|
|
|
|
2022-07-22 12:53:34 +00:00
|
|
|
## Dev Setup
|
2022-07-22 12:05:59 +00:00
|
|
|
|
|
|
|
|
`.env`:
|
|
|
|
|
```
|
|
|
|
|
MATRIX_HOMESERVER=https://matrix.org
|
|
|
|
|
MATRIX_USER_ID=@YOURBOT:matrix.org
|
|
|
|
|
MATRIX_PASSWORD="changeme"
|
|
|
|
|
MATRIX_DEVICE_NAME=my-bot-server
|
|
|
|
|
MATRIX_VERIFY_SSL=True
|
|
|
|
|
MATRIX_STORE_PATH=/abs/path/to/persistent-store
|
|
|
|
|
BOT_ROUTING_KEYS="{\"room1\": \"!XXXX:matrix.org\", \"room2\": \"!YYYYY:matrix.org\"}"
|
|
|
|
|
BOT_BEARER_TOKEN="changeme"
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
source .env
|
|
|
|
|
poetry install
|
|
|
|
|
poetry run start
|
|
|
|
|
```
|
|
|
|
|
|
2022-07-22 08:42:44 +00:00
|
|
|
## License
|
|
|
|
|
|
2022-07-22 12:05:59 +00:00
|
|
|
```
|
2022-07-22 08:42:44 +00:00
|
|
|
matrix-ops-bot
|
|
|
|
|
Copyright (C) 2022 Abel Luck <abel@guardianproject.info>
|
|
|
|
|
|
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
|
|
|
it under the terms of the GNU Affero General Public License as
|
|
|
|
|
published by the Free Software Foundation, either version 3 of the
|
|
|
|
|
License, or (at your option) any later version.
|
|
|
|
|
|
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
|
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
GNU Affero General Public License for more details.
|
|
|
|
|
|
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
|
|
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2022-12-01 13:47:27 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This project uses pieces of [maubot/gitlab](https://github.com/maubot/gitlab),
|
|
|
|
|
which is also AGPL. These files have been noted with a comment header.
|