Find & replace my-project-name to vetting-bot
This commit is contained in:
parent
995ad51b93
commit
6f680cad16
|
@ -5,35 +5,34 @@ name: Lint
|
||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ master ]
|
branches: [master]
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
lint:
|
lint:
|
||||||
|
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- name: Set up Python 3.9
|
- name: Set up Python 3.9
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.9
|
python-version: 3.9
|
||||||
|
|
||||||
- name: Install dependencies
|
- name: Install dependencies
|
||||||
run: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -U isort==5.6.4 flake8==3.8.4 flake8-comprehensions==3.3.1 black==20.8b1
|
pip install -U isort==5.6.4 flake8==3.8.4 flake8-comprehensions==3.3.1 black==20.8b1
|
||||||
|
|
||||||
- name: Check import statement sorting
|
- name: Check import statement sorting
|
||||||
run: |
|
run: |
|
||||||
isort -c --df my_project_name/ my-project-name tests
|
isort -c --df vetting_bot/ vetting-bot tests
|
||||||
|
|
||||||
- name: Python syntax errors, undefined names, etc.
|
- name: Python syntax errors, undefined names, etc.
|
||||||
run: |
|
run: |
|
||||||
flake8 . --count --show-source --statistics
|
flake8 . --count --show-source --statistics
|
||||||
|
|
||||||
- name: PEP8 formatting
|
- name: PEP8 formatting
|
||||||
run: |
|
run: |
|
||||||
black --check --diff my_project_name/ my-project-name tests
|
black --check --diff vetting_bot/ vetting-bot tests
|
||||||
|
|
53
README.md
53
README.md
|
@ -9,30 +9,29 @@ This repo contains a working Matrix echo bot that can be easily extended to your
|
||||||
|
|
||||||
Features include out-of-the-box support for:
|
Features include out-of-the-box support for:
|
||||||
|
|
||||||
* Bot commands
|
- Bot commands
|
||||||
* SQLite3 and Postgres database backends
|
- SQLite3 and Postgres database backends
|
||||||
* Configuration files
|
- Configuration files
|
||||||
* Multi-level logging
|
- Multi-level logging
|
||||||
* Docker
|
- Docker
|
||||||
* Participation in end-to-end encrypted rooms
|
- Participation in end-to-end encrypted rooms
|
||||||
|
|
||||||
## Projects using nio-template
|
## Projects using nio-template
|
||||||
|
|
||||||
* [anoadragon453/matrix-reminder-bot](https://github.com/anoadragon453/matrix-reminder-bot
|
- [anoadragon453/matrix-reminder-bot](https://github.com/anoadragon453/matrix-reminder-bot) - A matrix bot to remind you about things
|
||||||
) - A matrix bot to remind you about things
|
- [gracchus163/hopeless](https://github.com/gracchus163/hopeless) - COREbot for the Hope2020 conference Matrix server
|
||||||
* [gracchus163/hopeless](https://github.com/gracchus163/hopeless) - COREbot for the Hope2020 conference Matrix server
|
- [alturiak/nio-smith](https://github.com/alturiak/nio-smith) - A modular bot for @matrix-org that can be dynamically
|
||||||
* [alturiak/nio-smith](https://github.com/alturiak/nio-smith) - A modular bot for @matrix-org that can be dynamically
|
extended by plugins
|
||||||
extended by plugins
|
- [anoadragon453/msc-chatbot](https://github.com/anoadragon453/msc-chatbot) - A matrix bot for matrix spec proposals
|
||||||
* [anoadragon453/msc-chatbot](https://github.com/anoadragon453/msc-chatbot) - A matrix bot for matrix spec proposals
|
- [anoadragon453/matrix-episode-bot](https://github.com/anoadragon453/matrix-episode-bot) - A matrix bot to post episode links
|
||||||
* [anoadragon453/matrix-episode-bot](https://github.com/anoadragon453/matrix-episode-bot) - A matrix bot to post episode links
|
- [TheForcer/vision-nio](https://github.com/TheForcer/vision-nio) - A general purpose matrix chatbot
|
||||||
* [TheForcer/vision-nio](https://github.com/TheForcer/vision-nio) - A general purpose matrix chatbot
|
- [anoadragon453/drawing-challenge-bot](https://github.com/anoadragon453/drawing-challenge-bot) - A matrix bot to
|
||||||
* [anoadragon453/drawing-challenge-bot](https://github.com/anoadragon453/drawing-challenge-bot) - A matrix bot to
|
post historical, weekly art challenges from reddit to a room
|
||||||
post historical, weekly art challenges from reddit to a room
|
- [8go/matrix-eno-bot](https://github.com/8go/matrix-eno-bot) - A bot to be used as a) personal assistant or b) as
|
||||||
* [8go/matrix-eno-bot](https://github.com/8go/matrix-eno-bot) - A bot to be used as a) personal assistant or b) as
|
an admin tool to maintain your Matrix installation or server
|
||||||
an admin tool to maintain your Matrix installation or server
|
- [elokapina/bubo](https://github.com/elokapina/bubo) - Matrix bot to help with community management
|
||||||
* [elokapina/bubo](https://github.com/elokapina/bubo) - Matrix bot to help with community management
|
- [elokapina/middleman](https://github.com/elokapina/middleman) - Matrix bot to act as a middleman, for example as a support bot
|
||||||
* [elokapina/middleman](https://github.com/elokapina/middleman) - Matrix bot to act as a middleman, for example as a support bot
|
- [chc4/matrix-pinbot](https://github.com/chc4/matrix-pinbot) - Matrix bot for pinning messages to a dedicated channel
|
||||||
* [chc4/matrix-pinbot](https://github.com/chc4/matrix-pinbot) - Matrix bot for pinning messages to a dedicated channel
|
|
||||||
|
|
||||||
Want your project listed here? [Edit this
|
Want your project listed here? [Edit this
|
||||||
page!](https://github.com/anoadragon453/nio-template/edit/master/README.md)
|
page!](https://github.com/anoadragon453/nio-template/edit/master/README.md)
|
||||||
|
@ -43,14 +42,14 @@ See [SETUP.md](SETUP.md) for how to setup and run the template project.
|
||||||
|
|
||||||
## Project structure
|
## Project structure
|
||||||
|
|
||||||
*A reference of each file included in the template repository, its purpose and
|
_A reference of each file included in the template repository, its purpose and
|
||||||
what it does.*
|
what it does._
|
||||||
|
|
||||||
The majority of the code is kept inside of the `my_project_name` folder, which
|
The majority of the code is kept inside of the `vetting_bot` folder, which
|
||||||
is in itself a [python package](https://docs.python.org/3/tutorial/modules.html),
|
is in itself a [python package](https://docs.python.org/3/tutorial/modules.html),
|
||||||
the `__init__.py` file inside declaring it as such.
|
the `__init__.py` file inside declaring it as such.
|
||||||
|
|
||||||
To run the bot, the `my-project-name` script in the root of the codebase is
|
To run the bot, the `vetting-bot` script in the root of the codebase is
|
||||||
available. It will import the `main` function from the `main.py` file in the
|
available. It will import the `main` function from the `main.py` file in the
|
||||||
package and run it. To properly install this script into your python environment,
|
package and run it. To properly install this script into your python environment,
|
||||||
run `pip install -e .` in the project's root directory.
|
run `pip install -e .` in the project's root directory.
|
||||||
|
@ -65,7 +64,7 @@ their needs. Be sure never to check the edited `config.yaml` into source control
|
||||||
since it'll likely contain sensitive details such as passwords!
|
since it'll likely contain sensitive details such as passwords!
|
||||||
|
|
||||||
Below is a detailed description of each of the source code files contained within
|
Below is a detailed description of each of the source code files contained within
|
||||||
the `my_project_name` directory:
|
the `vetting_bot` directory:
|
||||||
|
|
||||||
### `main.py`
|
### `main.py`
|
||||||
|
|
||||||
|
@ -80,7 +79,7 @@ asking constantly asking for new events. Each time they do, the client gets a
|
||||||
sync token (stored in the `next_batch` field of the sync response). If the
|
sync token (stored in the `next_batch` field of the sync response). If the
|
||||||
client provides this token the next time it syncs (using the `since` parameter
|
client provides this token the next time it syncs (using the `since` parameter
|
||||||
on the `AsyncClient.sync` method), the homeserver will only return new event
|
on the `AsyncClient.sync` method), the homeserver will only return new event
|
||||||
*since* those specified by the given token.
|
_since_ those specified by the given token.
|
||||||
|
|
||||||
This token is saved and provided again automatically by using the
|
This token is saved and provided again automatically by using the
|
||||||
`client.sync_forever(...)` method.
|
`client.sync_forever(...)` method.
|
||||||
|
|
|
@ -58,9 +58,9 @@ RUN apk add --no-cache \
|
||||||
# Install python runtime modules. We do this before copying the source code
|
# Install python runtime modules. We do this before copying the source code
|
||||||
# such that these dependencies can be cached
|
# such that these dependencies can be cached
|
||||||
# This speeds up subsequent image builds when the source code is changed
|
# This speeds up subsequent image builds when the source code is changed
|
||||||
RUN mkdir -p /src/my_project_name
|
RUN mkdir -p /src/vetting_bot
|
||||||
COPY my_project_name/__init__.py /src/my_project_name/
|
COPY vetting_bot/__init__.py /src/vetting_bot/
|
||||||
COPY README.md my-project-name /src/
|
COPY README.md vetting-bot /src/
|
||||||
|
|
||||||
# Build the dependencies
|
# Build the dependencies
|
||||||
COPY setup.py /src/setup.py
|
COPY setup.py /src/setup.py
|
||||||
|
@ -68,7 +68,7 @@ RUN pip install --prefix="/python-libs" --no-warn-script-location "/src/.[postgr
|
||||||
|
|
||||||
# Now copy the source code
|
# Now copy the source code
|
||||||
COPY *.py *.md /src/
|
COPY *.py *.md /src/
|
||||||
COPY my_project_name/*.py /src/my_project_name/
|
COPY vetting_bot/*.py /src/vetting_bot/
|
||||||
|
|
||||||
# And build the final module
|
# And build the final module
|
||||||
RUN pip install --prefix="/python-libs" --no-warn-script-location "/src/.[postgres]"
|
RUN pip install --prefix="/python-libs" --no-warn-script-location "/src/.[postgres]"
|
||||||
|
@ -98,4 +98,4 @@ RUN apk add --no-cache \
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
|
|
||||||
# Start the bot
|
# Start the bot
|
||||||
ENTRYPOINT ["my-project-name", "/data/config.yaml"]
|
ENTRYPOINT ["vetting-bot", "/data/config.yaml"]
|
||||||
|
|
|
@ -53,14 +53,14 @@ RUN apk add --no-cache \
|
||||||
|
|
||||||
# Install python runtime modules. We do this before copying the source code
|
# Install python runtime modules. We do this before copying the source code
|
||||||
# such that these dependencies can be cached
|
# such that these dependencies can be cached
|
||||||
RUN mkdir -p /src/my_project_name
|
RUN mkdir -p /src/vetting_bot
|
||||||
COPY my_project_name/__init__.py /src/my_project_name/
|
COPY vetting_bot/__init__.py /src/vetting_bot/
|
||||||
COPY README.md my-project-name /src/
|
COPY README.md vetting-bot /src/
|
||||||
COPY setup.py /src/setup.py
|
COPY setup.py /src/setup.py
|
||||||
RUN pip install -e "/src/.[postgres]"
|
RUN pip install -e "/src/.[postgres]"
|
||||||
|
|
||||||
# Now copy the source code
|
# Now copy the source code
|
||||||
COPY my_project_name/*.py /src/my_project_name/
|
COPY vetting_bot/*.py /src/vetting_bot/
|
||||||
COPY *.py /src/
|
COPY *.py /src/
|
||||||
|
|
||||||
# Specify a volume that holds the config file, SQLite3 database,
|
# Specify a volume that holds the config file, SQLite3 database,
|
||||||
|
@ -68,4 +68,4 @@ COPY *.py /src/
|
||||||
VOLUME ["/data"]
|
VOLUME ["/data"]
|
||||||
|
|
||||||
# Start the app
|
# Start the app
|
||||||
ENTRYPOINT ["my-project-name", "/data/config.yaml"]
|
ENTRYPOINT ["vetting-bot", "/data/config.yaml"]
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# Docker
|
# Docker
|
||||||
|
|
||||||
The docker image will run my-project-name with a SQLite database and
|
The docker image will run vetting-bot with a SQLite database and
|
||||||
end-to-end encryption dependencies included. For larger deployments, a
|
end-to-end encryption dependencies included. For larger deployments, a
|
||||||
connection to a Postgres database backend is recommended.
|
connection to a Postgres database backend is recommended.
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ Copy `sample.config.yaml` to a file named `config.yaml` inside of your newly
|
||||||
created `data` directory. Fill it out as you normally would, with a few minor
|
created `data` directory. Fill it out as you normally would, with a few minor
|
||||||
differences:
|
differences:
|
||||||
|
|
||||||
* The bot store directory should reside inside of the data directory so that it
|
- The bot store directory should reside inside of the data directory so that it
|
||||||
is not wiped on container restart. Change it from the default to
|
is not wiped on container restart. Change it from the default to
|
||||||
`/data/store`. There is no need to create this directory yourself, it will be
|
`/data/store`. There is no need to create this directory yourself, it will be
|
||||||
created on startup if it does not exist.
|
created on startup if it does not exist.
|
||||||
|
|
||||||
* Choose whether you want to use SQLite or Postgres as your database backend.
|
- Choose whether you want to use SQLite or Postgres as your database backend.
|
||||||
Postgres has increased performance over SQLite, and is recommended for
|
Postgres has increased performance over SQLite, and is recommended for
|
||||||
deployments with many users.
|
deployments with many users.
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ differences:
|
||||||
If using postgres, point to your postgres instance instead:
|
If using postgres, point to your postgres instance instead:
|
||||||
|
|
||||||
```
|
```
|
||||||
database: "postgres://username:password@postgres/my-project-name?sslmode=disable"
|
database: "postgres://username:password@postgres/vetting-bot?sslmode=disable"
|
||||||
```
|
```
|
||||||
|
|
||||||
**Note:** a postgres container is defined in `docker-compose.yaml` for your convenience.
|
**Note:** a postgres container is defined in `docker-compose.yaml` for your convenience.
|
||||||
|
@ -80,20 +80,20 @@ docker-compose up -d postgres
|
||||||
Start the bot with:
|
Start the bot with:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up my-project-name
|
docker-compose up vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
This will run the bot and log the output to the terminal. You can instead run
|
This will run the bot and log the output to the terminal. You can instead run
|
||||||
the container detached with the `-d` flag:
|
the container detached with the `-d` flag:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose up -d my-project-name
|
docker-compose up -d vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
(Logs can later be accessed with the `docker logs` command).
|
(Logs can later be accessed with the `docker logs` command).
|
||||||
|
|
||||||
This will use the `latest` tag from
|
This will use the `latest` tag from
|
||||||
[Docker Hub](https://hub.docker.com/somebody/my-project-name).
|
[Docker Hub](https://hub.docker.com/somebody/vetting-bot).
|
||||||
|
|
||||||
If you would rather run from the checked out code, you can use:
|
If you would rather run from the checked out code, you can use:
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ remove the option altogether to allow all addresses.
|
||||||
To update the container, navigate to the bot's `docker` directory and run:
|
To update the container, navigate to the bot's `docker` directory and run:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker-compose pull my-project-name
|
docker-compose pull vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
Then restart the bot.
|
Then restart the bot.
|
||||||
|
@ -124,26 +124,26 @@ Then restart the bot.
|
||||||
## Systemd
|
## Systemd
|
||||||
|
|
||||||
A systemd service file is provided for your convenience at
|
A systemd service file is provided for your convenience at
|
||||||
[my-project-name.service](my-project-name.service). The service uses
|
[vetting-bot.service](vetting-bot.service). The service uses
|
||||||
`docker-compose` to start and stop the bot.
|
`docker-compose` to start and stop the bot.
|
||||||
|
|
||||||
Copy the file to `/etc/systemd/system/my-project-name.service` and edit to
|
Copy the file to `/etc/systemd/system/vetting-bot.service` and edit to
|
||||||
match your setup. You can then start the bot with:
|
match your setup. You can then start the bot with:
|
||||||
|
|
||||||
```
|
```
|
||||||
systemctl start my-project-name
|
systemctl start vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
and stop it with:
|
and stop it with:
|
||||||
|
|
||||||
```
|
```
|
||||||
systemctl stop my-project-name
|
systemctl stop vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
To run the bot on system startup:
|
To run the bot on system startup:
|
||||||
|
|
||||||
```
|
```
|
||||||
systemctl enable my-project-name
|
systemctl enable vetting-bot
|
||||||
```
|
```
|
||||||
|
|
||||||
## Building the image
|
## Building the image
|
||||||
|
@ -152,5 +152,5 @@ To build a production image from source, use the following `docker build` comman
|
||||||
from the repo's root:
|
from the repo's root:
|
||||||
|
|
||||||
```
|
```
|
||||||
docker build -t somebody/my-project-name:latest -f docker/Dockerfile .
|
docker build -t somebody/vetting-bot:latest -f docker/Dockerfile .
|
||||||
```
|
```
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
version: '3.1' # specify docker-compose version
|
version: "3.1" # specify docker-compose version
|
||||||
|
|
||||||
volumes:
|
volumes:
|
||||||
# Set up with `docker volume create ...`. See docker/README.md for more info.
|
# Set up with `docker volume create ...`. See docker/README.md for more info.
|
||||||
|
@ -8,8 +8,8 @@ volumes:
|
||||||
|
|
||||||
services:
|
services:
|
||||||
# Runs from the latest release
|
# Runs from the latest release
|
||||||
my-project-name:
|
vetting-bot:
|
||||||
image: somebody/my-project-name
|
image: somebody/vetting-bot
|
||||||
restart: always
|
restart: always
|
||||||
volumes:
|
volumes:
|
||||||
- data_volume:/data
|
- data_volume:/data
|
||||||
|
@ -61,4 +61,4 @@ services:
|
||||||
volumes:
|
volumes:
|
||||||
- pg_data_volume:/var/lib/postgresql/data
|
- pg_data_volume:/var/lib/postgresql/data
|
||||||
environment:
|
environment:
|
||||||
POSTGRES_PASSWORD: somefancypassword
|
POSTGRES_PASSWORD: somefancypassword
|
||||||
|
|
|
@ -3,11 +3,11 @@ Description=A matrix bot that does amazing things!
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
User=my-project-name
|
User=vetting-bot
|
||||||
Group=my-project-name
|
Group=vetting-bot
|
||||||
WorkingDirectory=/path/to/my-project-name/docker
|
WorkingDirectory=/path/to/vetting-bot/docker
|
||||||
ExecStart=/usr/bin/docker-compose up my-project-name
|
ExecStart=/usr/bin/docker-compose up vetting-bot
|
||||||
ExecStop=/usr/bin/docker-compose stop my-project-name
|
ExecStop=/usr/bin/docker-compose stop vetting-bot
|
||||||
RemainAfterExit=yes
|
RemainAfterExit=yes
|
||||||
Restart=always
|
Restart=always
|
||||||
RestartSec=3
|
RestartSec=3
|
||||||
|
|
|
@ -19,7 +19,7 @@ matrix:
|
||||||
# If this device ID already exists, messages will be dropped silently in encrypted rooms
|
# If this device ID already exists, messages will be dropped silently in encrypted rooms
|
||||||
device_id: ABCDEFGHIJ
|
device_id: ABCDEFGHIJ
|
||||||
# What to name the logged in device
|
# What to name the logged in device
|
||||||
device_name: my-project-name
|
device_name: vetting-bot
|
||||||
|
|
||||||
storage:
|
storage:
|
||||||
# The database connection string
|
# The database connection string
|
||||||
|
|
|
@ -11,7 +11,7 @@ if [ $# -ge 1 ]
|
||||||
then
|
then
|
||||||
files=$*
|
files=$*
|
||||||
else
|
else
|
||||||
files="my_project_name my-project-name tests"
|
files="vetting_bot vetting-bot tests"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Linting these locations: $files"
|
echo "Linting these locations: $files"
|
||||||
|
|
Loading…
Reference in New Issue