uniberry/lokibot
Archived
2
Fork 0
Gatekeeper bot for the Unimore Informatica unofficial Matrix space https://loki.steffo.eu
This repository has been archived on 2026-05-25. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
  • Python 63.6%
  • HTML 32.3%
  • CSS 2.7%
  • Dockerfile 1.4%
Find a file
2023-09-16 14:15:02 +02:00
.github Fix typo 2022-12-23 03:00:37 +01:00
.idea lokiunimore.telegram: Create bot skeleton and allow user creation 2023-09-16 14:15:02 +02:00
.vscode Create skeleton of the project 2022-09-04 21:01:56 +02:00
lokiunimore lokiunimore.telegram: Create bot skeleton and allow user creation 2023-09-16 14:15:02 +02:00
.dockerignore Create .dockerignore symlink 2022-12-22 04:28:45 +01:00
.gitignore Project: Ignore *.session and *.session-journal files generated by Telethon 2023-09-16 14:13:00 +02:00
Dockerfile Fix typo in dockerfile 2023-05-20 19:36:07 +02:00
LICENSE.txt Create LICENSE.txt 2022-09-12 09:14:37 +02:00
poetry.lock lokiunimore: Upgrade dependencies 2023-09-15 21:19:05 +02:00
pyproject.toml lokiunimore: Bump version to 0.8.0 2023-09-15 21:19:06 +02:00
README.md Update README 2023-05-20 19:29:47 +02:00

Loki Bot

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

Website On PyPI Chat

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.