Skip to content

Commit

Permalink
Migrate to poetry
Browse files Browse the repository at this point in the history
  • Loading branch information
raidensakura committed Dec 22, 2023
1 parent 2df3b01 commit 4c89469
Show file tree
Hide file tree
Showing 8 changed files with 1,442 additions and 1,154 deletions.
2 changes: 1 addition & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,13 @@ temp/
test.py

# Other stuff
requirements.txt
.env.example
.gitignore
.dockerignore
.github/
app.json
Procfile
pyproject.toml
*.md
.*.json
Dockerfile
Expand Down
31 changes: 17 additions & 14 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,27 @@ FROM python:3.11-alpine as base

RUN apk update && apk add git \
# pillow dependencies
jpeg-dev zlib-dev
jpeg-dev zlib-dev && \
adduser -D -h /home/modmail -g 'Modmail' modmail
ENV PIP_DISABLE_PIP_VERSION_CHECK=1
USER modmail
WORKDIR /home/modmail

FROM base as python-deps
FROM base as poetry

RUN apk add --virtual build-deps build-base gcc libffi-dev
COPY requirements.txt /
RUN pip install --prefix=/inst -U -r /requirements.txt
RUN pip install -U poetry
COPY poetry.lock pyproject.toml /home/modmail/
RUN python -m poetry export -o requirements.txt

FROM base as runtime
FROM base as deps

ENV USING_DOCKER yes
COPY --from=python-deps /inst /usr/local
COPY --from=poetry /home/modmail/requirements.txt /home/modmail/

COPY . /modmail
WORKDIR /modmail
RUN pip install -r requirements.txt --user

CMD ["python", "bot.py"]
FROM deps as runtime

ENV PATH=/home/modmail/.local/bin:$PATH
COPY --chown=modmail:modmail . .

RUN adduser --disabled-password --gecos '' app && \
chown -R app /modmail
USER app
CMD ["python", "bot.py"]
35 changes: 0 additions & 35 deletions Pipfile

This file was deleted.

998 changes: 0 additions & 998 deletions Pipfile.lock

This file was deleted.

102 changes: 25 additions & 77 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,63 +1,27 @@
<div align="center">
<img src="https://modmail-docs.netlify.app/logo-long.png" align="center">
<br>
<strong><i>Fork of a feature-rich Modmail bot for Discord written in Python.</i></strong>
<br>
<br>

<a href="#">
<img src="https://img.shields.io/badge/Version-4.1.0-7d5edd?style=shield&logo=https://modmail-docs.netlify.app/favicon.png">
</a>
<a href="https://discord.gg/cnUpwrnpYb">
<img src="https://img.shields.io/discord/1079074933008781362.svg?label=Discord&logo=Discord&colorB=7289da&style=shield" alt="Support">
</a>
<a href="https://ko-fi.com/raidensakura">
<img src="https://img.shields.io/badge/kofi-donate-gold.svg?style=shield&logo=Ko-fi" alt="Ko-fi">
</a>
<a href="https://www.python.org/downloads/">
<img src="https://img.shields.io/badge/Compatible%20With-Python%203.8%20|%203.9%20|%203.10%20|%203.11-blue.svg?style=shield&logo=Python" alt="Made with Python 3.8">
</a>
<a href="https://github.com/ambv/black">
<img src="https://img.shields.io/badge/Code%20Style-Black-black?style=shield">
</a>
<a href="https://github.com/modmail-dev/modmail/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-agpl-e74c3c.svg?style=shield" alt="MIT License">
</a>
<img src="https://modmail-docs.netlify.app/logo-long.png" align="center"><br>
<strong><i>Raiden's personal fork of Python Discord Modmail bot.</i></strong><br><br>

<a href="#"><img src="https://img.shields.io/badge/Version-4.1.0-7d5edd?style=shield&logo=https://modmail-docs.netlify.app/favicon.png"></a>
<a href="https://www.python.org/downloads/"><img src="https://img.shields.io/badge/Python-3.8_--_3.11-blue.svg?style=shield&logo=Python" alt="Made with Python 3.8"></a>
<a href="https://github.com/ambv/black"><img src="https://img.shields.io/badge/Code%20Style-Black-black?style=shield"></a>
<a href="https://github.com/modmail-dev/modmail/blob/master/LICENSE"><img src="https://img.shields.io/badge/License-AGPL--3.0-e74c3c.svg?style=shield" alt="MIT License"></a>
<a href="https://discord.gg/cnUpwrnpYb"><img src="https://img.shields.io/discord/616969119685935162.svg?label=Discord&logo=Discord&colorB=7289da&style=shield" alt="Support"></a>

<img src='https://github.com/raidensakura/modmail/assets/38610216/106e8fa3-6f8e-4b00-9968-f5c2f3108da0' align='center' width=500>
</div>

## Features

* **Highly Customisable:**
* Bot activity, prefix, category, log channel, etc.
* Command permission system.
* Interface elements (color, responses, reactions, etc.).
* Snippets and *command aliases*.
* Minimum duration for accounts to be created before allowed to contact Modmail (`account_age`).
* Minimum length for members to be in the guild before allowed to contact Modmail (`guild_age`).

* **Advanced Logging Functionality:**
* When you close a thread, Modmail will generate a [log link](https://logs.modmail.dev/example) and post it to your log channel.
* Native Discord dark-mode feel.
* Markdown/formatting support.
* Login via Discord to protect your logs (optional feature).
* See past logs of a user with `?logs`.
* Searchable by text queries using `?logs search`.
## Why hard fork?

* **Robust implementation:**
* Schedule tasks in human time, e.g. `?close in 2 hours silently`.
* Editing and deleting messages are synced.
* Support for the diverse range of message contents (multiple images, files).
* Paginated commands interfaces via reactions.
Several fundamental issues for the official Modmail require fixes that are backward-incompatible, hence I decided to make this fork since it's unlikely my PR will be accepted. As this is a pretty niche use-case, most users should probably not use this. As a disclaimer, **I will not be responsible for any damage caused to your Modmail instance by using my fork.** This is made public simply for the spirit of open-source software.

This list is ever-growing thanks to active development and our exceptional contributors. See a full list of documented commands by using the `?help` command.
This is mainly maintained by [@raidensakura](https://github.com/raidensakura) and [@khakers](https://github.com/khakers).

## Installation

This is a general installation guide. Refer to the [documentation](https://modmail-docs.netlify.app) for detailed user guide.
This is a general installation guide for developers. Refer to the [documentation](https://modmail-docs.netlify.app) for user guide.

This guide assumes you have git, and a supported Python version installed and added to system PATH.
This guide assumes you have installed **git**, a **compatible Python version** and [**Poetry**](https://python-poetry.org/) installed.

1. Clone the repository
```console
Expand All @@ -67,19 +31,14 @@ This guide assumes you have git, and a supported Python version installed and ad
2. Create a Discord bot account, grant the necessary intents, and invite the bot.
3. Create a free MongoDB database.
4. Rename the file `.env.example` to `.env` and fill it with appropriate values
5. Update pip, install pipenv, and install dependencies using pipenv
```console
$ pip install -U pip
$ pip install pipenv
$ pipenv install
```
6. Start the bot
5. Install the Python dependencies and run the bot
```console
$ pipenv run bot
$ poetry install --no-root
$ poetry run bot.py
```
7. Load the logviewer plugin included with Modmail with `?plugin load @local/logviewer`
7. [Optional] Load the logviewer plugin with `[p]plugin load raidensakura/modmail-plugins/logviewer@main`

### Running the Docker Image
## Running the Docker Image

This guide assume you already have Docker or Docker Compose installed.

Expand All @@ -91,24 +50,13 @@ This guide assume you already have Docker or Docker Compose installed.
```console
$ docker compose up -d
```
## Plugins

Modmail supports the use of third-party plugins to extend or add functionalities to the bot.
Plugins allow niche features as well as anything else outside of the scope of the core functionality of Modmail.

You can find a list of third-party plugins using the `?plugins registry` command on the bot or by reading through the official [REGISTRY.json](https://github.com/modmail-dev/modmail/blob/master/plugins/registry.json).

To develop your own, check out the [plugins documentation](https://github.com/modmail-dev/modmail/wiki/Plugins).

Plugins requests and support are available in the [Modmail Support Server](https://discord.gg/cnUpwrnpYb).

## Support & Issues

Issues with the bot can be opened through [GitHub Issues](https://github.com/raidensakura/modmail/issues/new/choose).
Issues with this fork can be opened through [GitHub Issues](https://github.com/raidensakura/modmail/issues/new/choose).

Support for this forked version of Modmail can be requested through [Raiden's Discord server](https://dsc.gg/transience).
As I don't have a dedicated team to answer questions and provide help, it will be be answered when I'm available.
As I don't have a dedicated team to answer questions and provide help, it will be answered based on my availability.

## Contributing

Expand All @@ -118,18 +66,18 @@ The [develop](https://github.com/raidensakura/modmail/tree/develop) branch is wh

This project has included pre-commit script that automatically runs black and ruff linter on every commit.

1. Install development dependencies inside pipenv
1. Install development dependencies
```console
$ pipenv install --dev
$ poetry install --only dev
```
2. Install the pre-commit hook
```console
$ pre-commit install
$ poetry run pre-commit install
```
Alternatively, you can also lint the codebase manually

```console
$ black .
$ ruff .
$ poetry run black .
$ poetry run ruff .
```
Loading

0 comments on commit 4c89469

Please sign in to comment.