notflixbot/README.md

162 lines
4.8 KiB
Markdown

# notflixbot
[![Build Status](https://jenkins.sudo.is/buildStatus/icon?job=ben%2Fnotflixbot%2Fmain&style=flat-square)](https://jenkins.sudo.is/job/ben/job/notflixbot/job/main/)
![Docker Image Version (latest semver)](https://img.shields.io/docker/v/benediktkr/notflixbot?sort=semver&style=flat-square)
![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/benediktkr/notflixbot?sort=date&style=flat-square)
![](neo.jpeg)
a general purpose matrix bot for
[matrix.sudo.is](https://matrix.sudo.is), trying to be extensible.
## features
* matrix bot based on [matrix-nio](https://github.com/poljar/matrix-nio)
* show youtube titles and link to invidous
* add a movie to [radarr](https://github.com/Radarr/Radarr) from imdb link with `!add`
* webhooks listener. handles radarr, sonarr, grafana, [jellyfin](https://github.com/jellyfin/jellyfin-plugin-webhook), slack and custom webhooks
* uses a zeromq `PAIR` socket over inproc transport between webhooks and bot
## usage
the bot answers to the following commands by default:
* `!add`: usage: `!add $IMDB_URL`
* `!ruok`: check if the bot is ok
* `!whoami`: show your user id
* `!key_sync`: force a key sync (experimental)
* `!help`: show help
## configuration
please see [config-sample.json](config-sample.json).
by default the webhooks will listen on `localhost:3000`, but you can change it by setting
```json
"webhook": {
"host": "0.0.0.0",
"port": 3005
}
```
in the config file
## running the bot
```shell
usage: notflixbot [-h] [-c CONFIG] [-d] subcmd ...
positional arguments:
subcmd
start start matrix bot
restore_login start new matrix session
webhook start webhook http server
nio low-level stuff, helpful for dev
optional arguments:
-h, --help show this help message and exit
-c CONFIG, --config CONFIG
path to config file (default: /etc/config.json)
-d, --debug print debug output (default: False)
```
### start the bot
simplest way to start the bot, will use the default configfile `/etc/notflixbot.json`:
```shell
$ notflixbot start
notflixbot 0.1.2
matrix bot running as @notflixbot:example.com
matrix client syncing forever
polling zmq socket
webhook listening on http://127.0.0.1:3033
```
you can use the `-c` flag to specify a path to a different config file:
```shell
notflixbot -c /path/to/a/different/config.json
```
### docker
you can also use docker (build from `Dockerfile` or use pre-built image):
```shell
mkdir ${PWD}/data
docker run --name notflixbot --rm -v ${PWD}/data:/data -v ${PWD}/config.json:/etc/config.json benediktkr/notflixbot:latest
```
make sure to configure `credentials_path` and `storage_path` to be
somewhere persisent, for example in `/data` in this example.
### logging in
your config has to set `credentials_path` to a path to a file that the
bot can read and write, that will store the credentials (access token,
device id and user id) for the bot.
log in and create the file with:
```shell
$ notflixbot restore_login -c config.json
Password:
```
you can also create the file if you have an access token and device_id
handy:
```json
{
"user_id": "@notflixbot:exmaple.com",
"device_id": "ABCDEF1234",
"acces_token": "abc123
}
```
### nio shorthand commands:
```
usage: notflixbot nio [-h] --forget-room FORGET_ROOM
optional arguments:
-h, --help show this help message and exit
--forget-room FORGET_ROOM
canonical_alias or room_id
```
## install libolm depdenency
```shell
apt-get install libolm-dev
```
if this breaks, its because i install -- user pycryptodome
```console
$ python3 -m pip install --user pycryptodome
Collecting pycryptodome
Downloading pycryptodome-3.18.0-cp35-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (2.1 MB)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 2.1/2.1 MB 36.9 MB/s eta 0:00:00
Installing collected packages: pycryptodome
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
matrix-nio 0.19.0 requires aiofiles<0.7.0,>=0.6.0, but you have aiofiles 0.8.0 which is incompatible.
matrix-nio 0.19.0 requires aiohttp-socks<0.8.0,>=0.7.0, but you have aiohttp-socks 0.5.3 which is incompatible.
matrix-nio 0.19.0 requires h11<0.13.0,>=0.12.0, but you have h11 0.13.0 which is incompatible.
matrix-nio 0.19.0 requires jsonschema<4.0.0,>=3.2.0, but you have jsonschema 4.17.3 which is incompatible.
matrix-nio 0.19.0 requires unpaddedbase64<3.0.0,>=2.1.0, but you have unpaddedbase64 1.1.0 which is incompatible.
Successfully installed pycryptodome-3.18.0
[notice] A new release of pip available: 22.2.2 -> 23.2
[notice] To update, run: python3 -m pip install --upgrade pip
$ python3 -m pip uninstall --user crypto
```