Skip to content

Commit

Permalink
Merge pull request #4 from interactions
Browse files Browse the repository at this point in the history
Interactions + CI/CD + Pagination
  • Loading branch information
NathanealV authored Sep 9, 2023
2 parents 20681ab + b716589 commit 0f17b16
Show file tree
Hide file tree
Showing 23 changed files with 1,339 additions and 652 deletions.
3 changes: 3 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[flake8]
max-line-length = 88
extend-ignore = E203
42 changes: 42 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# yaml-language-server: $schema=https://raw.githubusercontent.com/SchemaStore/schemastore/master/src/schemas/json/github-workflow.json

name: ModMail CD

on:
workflow_run:
workflows: ["ModMail CI"]
types:
- completed
workflow_dispatch:

jobs:
lint-playbook:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run ansible-lint
uses: ansible-community/ansible-lint-action@main
run-ansible-playbook:
runs-on: ubuntu-latest
needs: [lint-playbook]
steps:
- uses: actions/checkout@v3
- name: Install Ansible via Apt
run: >
sudo apt update &&
sudo apt install software-properties-common &&
sudo apt-add-repository --yes --update ppa:ansible/ansible &&
sudo apt install ansible
- name: Write Inventory to File
env:
INVENTORY: ${{ secrets.INVENTORY }}
run: 'echo "$INVENTORY" > inventory'
- name: Install SSH Key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.ANSIBLE_KEY }}
name: ansible
known_hosts: ${{ secrets.KNOWN_HOSTS }}
- name: Run Ansible Playbook
run: |
ansible-playbook -i inventory playbook.yml
39 changes: 39 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: ModMail CI

on:
push:
branches: ["main"]

workflow_dispatch:

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}

jobs:
build-and-publish-latest:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set Up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to the Container registry
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ celerybeat.pid
*.sage.py

# Environments
modmail.env
.env
.venv
env/
Expand Down Expand Up @@ -129,4 +130,4 @@ dmypy.json
.pyre/

config.json
modmail.db
modmail.db
20 changes: 20 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
If you are reading this page, then thank you for your interest in contributing towards the bot.
We are grateful for any help, however, please ensure you follow the guidelines laid out below
and ensure that any code you produce for modmail.py is licensed with the GNU GPL v3.

# Contributions

Not all contribution PRs (read below) will be accepted.
For ideas as to what to contribute, please refer to the GitHub issues or contact a member of the development team.

Bug fixes and optimisations are also greatly appreciated!

# VCS

1. Create a new branch (and fork if applicable). Label it appropriately.
2. Make the changes on that branch.
3. Commit to and push the changes.
4. Create a PR from your branch to `main`.
5. A maintainer will then review your PR.

If you have questions, please ask a maintainer.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,30 @@

ModMail, but in Python

# Configuration

- `token`: The bot's user token retrieved from Discord Developer Portal.
- `application_id`: The bot's application ID retrieved from Discord Developer Portal.
- `guild`: The guild ID.
- `channel`: Modmail channel ID in specified guild (must be `TextChannel`).
- `prefix`: The bot prefix (needed for slash command sync command).
- `status`: The bot status.
- `id_prefix`: The bot prefix for persistent views (e.g., `mm`)

## Sample `config.json`

```json
{
"token": "abc123",
"application_id": 1234567890,
"guild": 1234567890,
"channel": 1234567890,
"prefix": "]",
"status": "DM to contact",
"id_prefix": "mm"
}
```

# Running the bot

1. Navigate to the root directory.
Expand All @@ -11,7 +35,7 @@ cd <path>/modmail.py
```

2. Copy the `config.example.json`, rename to `config.json`, and replace the relevant values.
If you want to inject the config at runtime using environment variables, don't replace the values.
If you want to inject the config at runtime using environment variables, don't replace the values.

3. Build the bot using Docker.

Expand All @@ -28,6 +52,7 @@ docker container run --name modmail \
```

As aforementioned, you can also inject environment variables.

```
docker container run --name modmail \
-v database:/database \
Expand All @@ -37,3 +62,7 @@ docker container run --name modmail \
-e MODMAIL_PREFIX=! \
modmail-py
```

# Contributions

For information regarding contributing to this project, please read [CONTRIBUTING.md](CONTRIBUTING.md).
160 changes: 0 additions & 160 deletions cogs/command_actions.py

This file was deleted.

Loading

0 comments on commit 0f17b16

Please sign in to comment.