Merge pull request #3240 from FSG-Cat/PantalFixes-and-Improvements

Improve Pantalaimon Support in Draupnir and add Mjolnir support
This commit is contained in:
Slavi Pantaleev
2024-03-25 07:05:06 +02:00
committed by GitHub
7 changed files with 111 additions and 31 deletions

View File

@ -48,13 +48,13 @@ matrix_bot_draupnir_access_token: ""
# User name and password for the bot. Required when using Pantalaimon.
# (Otherwise provide `matrix_bot_draupnir_access_token` instead.)
matrix_bot_draupnir_pantalaimon_username: "bot.draupnir"
matrix_bot_draupnir_pantalaimon_username: ""
matrix_bot_draupnir_pantalaimon_password: ""
# The room ID where people can use the bot. The bot has no access controls, so
# anyone in this room can use the bot - secure your room!
# This should be a room alias or room ID - not a matrix.to URL.
# Note: draupnir is fairly verbose - expect a lot of messages from it.
# Note: Draupnir is fairly verbose - expect a lot of messages from it.
matrix_bot_draupnir_management_room: ""
# Endpoint URL that Draupnir uses to interact with the matrix homeserver (client-server API).

View File

@ -37,15 +37,34 @@ matrix_bot_mjolnir_systemd_required_services_list_custom: []
# List of systemd services that matrix-bot-mjolnir.service wants
matrix_bot_mjolnir_systemd_wanted_services_list: []
# The access token for the bot user
# Whether Mjolnir should talk to the homeserver through Pantalaimon
# If true, then other variables must be provided including pointing
# `matrix_bot_mjolnir_homeserver_url` to the Pantalaimon URL.
matrix_bot_mjolnir_pantalaimon_use: false
# The access token for the bot user. Required when NOT using Pantalaimon.
# (Otherwise provide `matrix_bot_mjolnir_pantalaimon_username` and `matrix_bot_mjolnir_pantalaimon_password` instead.)
matrix_bot_mjolnir_access_token: ""
# User name and password for the bot. Required when using Pantalaimon.
# (Otherwise provide `matrix_bot_mjolnir_access_token` instead.)
matrix_bot_mjolnir_pantalaimon_username: ""
matrix_bot_mjolnir_pantalaimon_password: ""
# The room ID where people can use the bot. The bot has no access controls, so
# anyone in this room can use the bot - secure your room!
# This should be a room alias or room ID - not a matrix.to URL.
# Note: Mjolnir is fairly verbose - expect a lot of messages from it.
matrix_bot_mjolnir_management_room: ""
# Endpoint URL that Mjolnir uses to interact with the matrix homeserver (client-server API).
# Set this to the pantalaimon URL if you're using that.
matrix_bot_mjolnir_homeserver_url: ""
# Endpoint URL that Mjolnir could use to fetch events related to reports (client-server API and /_synapse/),
# only set this to the public-internet homeserver client API URL, do NOT set this to the pantalaimon URL.
matrix_bot_mjolnir_raw_homeserver_url: ""
# Default configuration template which covers the generic use case.
# You can customize it by controlling the various variables inside it.
#

View File

@ -1,9 +1,21 @@
---
- name: Fail if required variables are undefined
- name: Fail if required matrix-bot-mjolnir variables are undefined
ansible.builtin.fail:
msg: "The `{{ item }}` variable must be defined and have a non-null value."
msg: "The `{{ item.name }}` variable must be defined and have a non-null value."
with_items:
- "matrix_bot_mjolnir_access_token"
- "matrix_bot_mjolnir_management_room"
when: "vars[item] == '' or vars[item] is none"
- {'name': 'matrix_bot_mjolnir_access_token', when: "{{ not matrix_bot_mjolnir_pantalaimon_use }}"}
- {'name': 'matrix_bot_mjolnir_management_room', when: true}
- {'name': 'matrix_bot_mjolnir_container_network', when: true}
- {'name': 'matrix_bot_mjolnir_homeserver_url', when: true}
- {'name': 'matrix_bot_mjolnir_raw_homeserver_url', when: true}
- {'name': 'matrix_bot_mjolnir_pantalaimon_username', when: "{{ matrix_bot_mjolnir_pantalaimon_use }}"}
- {'name': 'matrix_bot_mjolnir_pantalaimon_password', when: "{{ matrix_bot_mjolnir_pantalaimon_use }}"}
when: "item.when | bool and (vars[item.name] == '' or vars[item.name] is none)"
- name: Fail if inappropriate variables are defined
ansible.builtin.fail:
msg: "The `{{ item.name }}` variable must be undefined or have a null value."
with_items:
- {'name': 'matrix_bot_mjolnir_access_token', when: "{{ matrix_bot_mjolnir_pantalaimon_use }}"}
when: "item.when | bool and not (vars[item.name] == '' or vars[item.name] is none)"

View File

@ -1,32 +1,34 @@
# Endpoint URL that Mjolnir uses to interact with the matrix homeserver (client-server API),
# set this to the pantalaimon URL if you're using that.
homeserverUrl: "{{ matrix_homeserver_url }}"
homeserverUrl: {{ matrix_bot_mjolnir_homeserver_url | to_json }}
# Endpoint URL that Mjolnir could use to fetch events related to reports (client-server API and /_synapse/),
# only set this to the public-internet homeserver client API URL, do NOT set this to the pantalaimon URL.
rawHomeserverUrl: "{{ matrix_homeserver_url }}"
rawHomeserverUrl: {{ matrix_bot_mjolnir_raw_homeserver_url | to_json }}
# Matrix Access Token to use, Mjolnir will only use this if pantalaimon.use is false.
accessToken: "{{ matrix_bot_mjolnir_access_token }}"
accessToken: {{ matrix_bot_mjolnir_access_token | to_json }}
{% if matrix_bot_mjolnir_pantalaimon_use %}
# Options related to Pantalaimon (https://github.com/matrix-org/pantalaimon)
#pantalaimon:
# # Whether or not Mjolnir will use pantalaimon to access the matrix homeserver,
# # set to `true` if you're using pantalaimon.
# #
# # Be sure to point homeserverUrl to the pantalaimon instance.
# #
# # Mjolnir will log in using the given username and password once,
# # then store the resulting access token in a file under dataPath.
# use: false
#
# # The username to login with.
# username: mjolnir
#
# # The password Mjolnir will login with.
# #
# # After successfully logging in once, this will be ignored, so this value can be blanked after first startup.
# password: your_password
pantalaimon:
# Whether or not Mjolnir will use pantalaimon to access the matrix homeserver,
# set to `true` if you're using pantalaimon.
#
# Be sure to point homeserverUrl to the pantalaimon instance.
#
# Mjolnir will log in using the given username and password once,
# then store the resulting access token in a file under dataPath.
use: true
# The username to login with.
username: {{ matrix_bot_mjolnir_pantalaimon_username | to_json }}
# The password Mjolnir will login with.
#
# After successfully logging in once, this will be ignored, so this value can be blanked after first startup.
password: {{ matrix_bot_mjolnir_pantalaimon_password | to_json }}
{% endif %}
# The path Mjolnir will store its state/data in, leave default ("/data/storage") when using containers.
dataPath: "/data"
@ -49,7 +51,7 @@ recordIgnoredInvites: false
#
# Note: By default, Mjolnir is fairly verbose - expect a lot of messages in this room.
# (see verboseLogging to adjust this a bit.)
managementRoom: "{{ matrix_bot_mjolnir_management_room }}"
managementRoom: {{ matrix_bot_mjolnir_management_room | to_json }}
# Whether Mjolnir should log a lot more messages in the room,
# mainly involves "all-OK" messages, and debugging messages for when mjolnir checks bans in a room.