mscbot github bot implementation in python
  • Python 98.3%
  • Jinja 1%
  • Dockerfile 0.5%
  • Shell 0.2%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
2022-11-23 16:54:25 +00:00
.github Move linting dependencies to setup.py and add linting instructions to README (#24) 2022-07-19 16:46:09 +01:00
comment_templates Add link to user guide in bot commands 2020-02-20 17:45:59 +00:00
docs Add some release documentation 2021-03-08 01:14:00 +00:00
scripts update msc repo name: matrix-doc -> matrix-spec-proposals 2022-07-18 11:26:24 +01:00
scripts-dev Enable execution bit and tidy up lint script 2021-03-09 16:24:06 +00:00
.gitignore current progress 2020-02-14 18:29:43 +00:00
command_handler.py Support @mscbot commands in PR review bodies (#26) 2022-11-22 18:21:58 +00:00
config.py Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
Dockerfile Change the Dockerfile to look for config.yaml at /config/config.yaml 2020-10-05 15:12:55 +01:00
errors.py Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
fcp_timers.py Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
LICENSE Add apache license 2020-02-20 16:26:12 +00:00
mscbot.py Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
README.md Support @mscbot commands in PR review bodies (#26) 2022-11-22 18:21:58 +00:00
sample.config.yaml update msc repo name: matrix-doc -> matrix-spec-proposals 2022-07-18 11:26:24 +01:00
setup.cfg Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
setup.py Move linting dependencies to setup.py and add linting instructions to README (#24) 2022-07-19 16:46:09 +01:00
storage.py Lint the codebase, add linting CI 2021-03-08 00:58:07 +00:00
webhook.py Inform requesters that they likely forgot to add a path if they hit https://<webhook_url>/ (#29) 2022-11-23 16:54:25 +00:00

MSCBot: Python Edition™

A bot to help facilitate the Matrix Spec Proposal Process.

However it is written in a generic way such that it can be used for any project wanting to make use of a similar process.

Installation

Getting the code

git clone https://github.com/matrix-org/mscbot-python && cd mscbot-python

Python dependencies

Create a virtual environment and activate it:

python -m venv venv
source venv/bin/activate

Install packages:

pip install -e .

OS dependencies

Install Postgres.

Create a user and a database:

sudo -u postgres psql
postgres=# create database mscbot;
postgres=# create user mscbot with encrypted password 'super-strong-password';
postgres=# grant all privileges on database mscbot to mscbot;

Config

Copy and update the config file:

cp sample.config.yaml config.yaml
vi config.yaml

Be sure to enter the postgres user, password and database details from above.

Server and webhook setup

On github:

  1. Go to your Github project -> Settings -> Webhooks
  2. Add a new webhook, point it to a URL that the bot can be accessed at
  3. Set the content type to application/json
  4. Come up with and set a secret (hint: use the uuid terminal command)
  5. Under events, select "Let me select individual events". Only the following need to be checked:
    • Issue comments
    • Pull request reviews
    • Pull request review comments

On your server:

Edit the config file and

  • add the webhook secret
  • configure the appropriate webhook path (/webhook by default). The bot will listen here for webhook hits from github

Usage

Activate the virtualenv and start mscbot:

source venv/bin/activate
python -m mscbot

Command line flags

The following command line options are available:

  • -c/config - The path to a config file. Defaults to ./config.yaml.

Docker

Getting the image

Either download the latest release from Dockerhub:

docker pull matrixdotorg/mscbot-python

Or build an image from the source locally:

docker build -t matrixdotorg/mscbot-python .

You'll also probably want a postgres container to hold your database.

Running

Put your config file somewhere and then mount it via a volume.

docker run -v /path/to/config/dir:/config matrixdotorg/mscbot-python python -m mscbot -c /config/config.yaml

User guide

See docs/user_guide.md.

Development

Several python dependencies are necessary to support development scripts. They can be installed by running:

# Activate your python environment
source venv/bin/activate

# Install development dependencies in editable mode
pip install -e ".[dev]"

Code linting

Before submitting a PR, make sure to lint your code:

./scripts-dev/lint.sh