Find & replace my-project-name to vetting-bot
This commit is contained in:
parent
995ad51b93
commit
6f680cad16
|
@ -5,35 +5,34 @@ name: Lint
|
|||
|
||||
on:
|
||||
push:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
pull_request:
|
||||
branches: [ master ]
|
||||
branches: [master]
|
||||
|
||||
jobs:
|
||||
lint:
|
||||
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
- uses: actions/checkout@v2
|
||||
- name: Set up Python 3.9
|
||||
uses: actions/setup-python@v2
|
||||
with:
|
||||
python-version: 3.9
|
||||
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
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
|
||||
- name: Install dependencies
|
||||
run: |
|
||||
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
|
||||
|
||||
- name: Check import statement sorting
|
||||
run: |
|
||||
isort -c --df my_project_name/ my-project-name tests
|
||||
- name: Check import statement sorting
|
||||
run: |
|
||||
isort -c --df vetting_bot/ vetting-bot tests
|
||||
|
||||
- name: Python syntax errors, undefined names, etc.
|
||||
run: |
|
||||
flake8 . --count --show-source --statistics
|
||||
- name: Python syntax errors, undefined names, etc.
|
||||
run: |
|
||||
flake8 . --count --show-source --statistics
|
||||
|
||||
- name: PEP8 formatting
|
||||
run: |
|
||||
black --check --diff my_project_name/ my-project-name tests
|
||||
- name: PEP8 formatting
|
||||
run: |
|
||||
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:
|
||||
|
||||
* Bot commands
|
||||
* SQLite3 and Postgres database backends
|
||||
* Configuration files
|
||||
* Multi-level logging
|
||||
* Docker
|
||||
* Participation in end-to-end encrypted rooms
|
||||
- Bot commands
|
||||
- SQLite3 and Postgres database backends
|
||||
- Configuration files
|
||||
- Multi-level logging
|
||||
- Docker
|
||||
- Participation in end-to-end encrypted rooms
|
||||
|
||||
## Projects using nio-template
|
||||
|
||||
* [anoadragon453/matrix-reminder-bot](https://github.com/anoadragon453/matrix-reminder-bot
|
||||
) - A matrix bot to remind you about things
|
||||
* [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
|
||||
extended by plugins
|
||||
* [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
|
||||
* [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
|
||||
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
|
||||
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/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
|
||||
- [anoadragon453/matrix-reminder-bot](https://github.com/anoadragon453/matrix-reminder-bot) - A matrix bot to remind you about things
|
||||
- [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
|
||||
extended by plugins
|
||||
- [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
|
||||
- [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
|
||||
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
|
||||
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/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
|
||||
|
||||
Want your project listed here? [Edit this
|
||||
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
|
||||
|
||||
*A reference of each file included in the template repository, its purpose and
|
||||
what it does.*
|
||||
_A reference of each file included in the template repository, its purpose and
|
||||
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),
|
||||
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
|
||||
package and run it. To properly install this script into your python environment,
|
||||
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!
|
||||
|
||||
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`
|
||||
|
||||
|
@ -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
|
||||
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
|
||||
*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
|
||||
`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
|
||||
# such that these dependencies can be cached
|
||||
# This speeds up subsequent image builds when the source code is changed
|
||||
RUN mkdir -p /src/my_project_name
|
||||
COPY my_project_name/__init__.py /src/my_project_name/
|
||||
COPY README.md my-project-name /src/
|
||||
RUN mkdir -p /src/vetting_bot
|
||||
COPY vetting_bot/__init__.py /src/vetting_bot/
|
||||
COPY README.md vetting-bot /src/
|
||||
|
||||
# Build the dependencies
|
||||
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
|
||||
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
|
||||
RUN pip install --prefix="/python-libs" --no-warn-script-location "/src/.[postgres]"
|
||||
|
@ -98,4 +98,4 @@ RUN apk add --no-cache \
|
|||
VOLUME ["/data"]
|
||||
|
||||
# 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
|
||||
# such that these dependencies can be cached
|
||||
RUN mkdir -p /src/my_project_name
|
||||
COPY my_project_name/__init__.py /src/my_project_name/
|
||||
COPY README.md my-project-name /src/
|
||||
RUN mkdir -p /src/vetting_bot
|
||||
COPY vetting_bot/__init__.py /src/vetting_bot/
|
||||
COPY README.md vetting-bot /src/
|
||||
COPY setup.py /src/setup.py
|
||||
RUN pip install -e "/src/.[postgres]"
|
||||
|
||||
# Now copy the source code
|
||||
COPY my_project_name/*.py /src/my_project_name/
|
||||
COPY vetting_bot/*.py /src/vetting_bot/
|
||||
COPY *.py /src/
|
||||
|
||||
# Specify a volume that holds the config file, SQLite3 database,
|
||||
|
@ -68,4 +68,4 @@ COPY *.py /src/
|
|||
VOLUME ["/data"]
|
||||
|
||||
# Start the app
|
||||
ENTRYPOINT ["my-project-name", "/data/config.yaml"]
|
||||
ENTRYPOINT ["vetting-bot", "/data/config.yaml"]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# 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
|
||||
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
|
||||
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
|
||||
`/data/store`. There is no need to create this directory yourself, it will be
|
||||
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
|
||||
deployments with many users.
|
||||
|
||||
|
@ -44,7 +44,7 @@ differences:
|
|||
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.
|
||||
|
@ -80,20 +80,20 @@ docker-compose up -d postgres
|
|||
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
|
||||
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).
|
||||
|
||||
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:
|
||||
|
||||
|
@ -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:
|
||||
|
||||
```
|
||||
docker-compose pull my-project-name
|
||||
docker-compose pull vetting-bot
|
||||
```
|
||||
|
||||
Then restart the bot.
|
||||
|
@ -124,26 +124,26 @@ Then restart the bot.
|
|||
## Systemd
|
||||
|
||||
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.
|
||||
|
||||
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:
|
||||
|
||||
```
|
||||
systemctl start my-project-name
|
||||
systemctl start vetting-bot
|
||||
```
|
||||
|
||||
and stop it with:
|
||||
|
||||
```
|
||||
systemctl stop my-project-name
|
||||
systemctl stop vetting-bot
|
||||
```
|
||||
|
||||
To run the bot on system startup:
|
||||
|
||||
```
|
||||
systemctl enable my-project-name
|
||||
systemctl enable vetting-bot
|
||||
```
|
||||
|
||||
## 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:
|
||||
|
||||
```
|
||||
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:
|
||||
# Set up with `docker volume create ...`. See docker/README.md for more info.
|
||||
|
@ -8,8 +8,8 @@ volumes:
|
|||
|
||||
services:
|
||||
# Runs from the latest release
|
||||
my-project-name:
|
||||
image: somebody/my-project-name
|
||||
vetting-bot:
|
||||
image: somebody/vetting-bot
|
||||
restart: always
|
||||
volumes:
|
||||
- data_volume:/data
|
||||
|
@ -61,4 +61,4 @@ services:
|
|||
volumes:
|
||||
- pg_data_volume:/var/lib/postgresql/data
|
||||
environment:
|
||||
POSTGRES_PASSWORD: somefancypassword
|
||||
POSTGRES_PASSWORD: somefancypassword
|
||||
|
|
|
@ -3,11 +3,11 @@ Description=A matrix bot that does amazing things!
|
|||
|
||||
[Service]
|
||||
Type=simple
|
||||
User=my-project-name
|
||||
Group=my-project-name
|
||||
WorkingDirectory=/path/to/my-project-name/docker
|
||||
ExecStart=/usr/bin/docker-compose up my-project-name
|
||||
ExecStop=/usr/bin/docker-compose stop my-project-name
|
||||
User=vetting-bot
|
||||
Group=vetting-bot
|
||||
WorkingDirectory=/path/to/vetting-bot/docker
|
||||
ExecStart=/usr/bin/docker-compose up vetting-bot
|
||||
ExecStop=/usr/bin/docker-compose stop vetting-bot
|
||||
RemainAfterExit=yes
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
|
|
@ -19,7 +19,7 @@ matrix:
|
|||
# If this device ID already exists, messages will be dropped silently in encrypted rooms
|
||||
device_id: ABCDEFGHIJ
|
||||
# What to name the logged in device
|
||||
device_name: my-project-name
|
||||
device_name: vetting-bot
|
||||
|
||||
storage:
|
||||
# The database connection string
|
||||
|
|
|
@ -11,7 +11,7 @@ if [ $# -ge 1 ]
|
|||
then
|
||||
files=$*
|
||||
else
|
||||
files="my_project_name my-project-name tests"
|
||||
files="vetting_bot vetting-bot tests"
|
||||
fi
|
||||
|
||||
echo "Linting these locations: $files"
|
||||
|
|
Loading…
Reference in New Issue