Skip to content
This repository has been archived by the owner on Sep 26, 2023. It is now read-only.
/ lokibot Public archive
generated from Steffo99/template-poetry

Gatekeeper bot for the Unimore Informatica unofficial Matrix space

License

Notifications You must be signed in to change notification settings

uniberry-info/lokibot

Repository files navigation

Loki Bot

Gatekeeper bot for the Unimore Informatica unofficial Matrix space, successor to Thor Bot.

WebsiteOn PyPIChat

Functionality

This bot monitors a pre-configured public Matrix space for join events, sending a welcome message to every new joiner.

The welcome message contains a link, which when clicked starts the user verification process:

  1. a page describing the bot is opened, and it allows users to login with a pre-configured OpenID Connect Identity Provider;
  2. the claims of the OIDC IdP are verified, and the user's email address is checked to verify that its domain matches a pre-configured RegEx with specific email requirements;
  3. if the email address fullfils all the requirements, an invitation to a different, pre-configured private Matrix space is sent to the user.

Additionally, the bot monitors for leave events from both spaces, deleting user data if no longer needed to protect the user's privacy.

Setting up a development environment

Dependencies

This project uses Poetry to manage the dependencies.

To install all dependencies in a venv, run:

$ poetry install

TIP: For easier venv management, you may want to set:

$ poetry config virtualenvs.in-project true

To activate the venv, run:

$ poetry shell

To run something in the venv without activating it, run:

$ poetry run <COMMAND>

Environment

Loki requires a lot of environment variables to be set, therefore it makes use of cfig to simplify the setup.

To view the current configuration, followed by a description of each variable, run:

$ poetry run python -m lokiunimore.config

Deploying in production

Use the pre-built Docker image, or build it from the provided Dockerfile.

Run the image without any command to view and validate the current configuration.

Run the image with the gunicorn -b 0.0.0.0:80 lokiunimore.web.app:rp_app command to launch the production web server on local port 80, expecting to be behind a reverse proxy.

Run the image with the lokiunimore.matrix command to launch the Matrix bot.