Skip to content

Commit

Permalink
Merge branch 'development' into patch-1
Browse files Browse the repository at this point in the history
  • Loading branch information
Taaku18 authored Jul 15, 2023
2 parents e806842 + 5ddb4e0 commit ecee83d
Show file tree
Hide file tree
Showing 18 changed files with 228 additions and 194 deletions.
1 change: 0 additions & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
TOKEN=MyBotToken
LOG_URL=https://logviewername.herokuapp.com/
GUILD_ID=1234567890
MODMAIL_GUILD_ID=1234567890
OWNERS=Owner1ID,Owner2ID,Owner3ID
CONNECTION_URI=mongodb+srv://mongodburi
6 changes: 3 additions & 3 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ Pull requests are the best way to propose changes to the codebase. We actively w
## Any contributions you make will be under the GNU Affero General Public License v3.0
In short, when you submit code changes, your submissions are understood to be under the same [GNU Affero General Public License v3.0](https://www.gnu.org/licenses/agpl-3.0.en.html) that covers the project. Feel free to contact the maintainers if that's a concern.

## Report bugs using [Github Issues](https://github.com/kyb3r/modmail/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new Issue](https://github.com/kyb3r/modmail/issues/new); it's that easy!
## Report bugs using [Github Issues](https://github.com/modmail-dev/modmail/issues)
We use GitHub issues to track public bugs. Report a bug by [opening a new Issue](https://github.com/modmail-dev/modmail/issues/new); it's that easy!

## Find pre-existing issues to tackle
Check out our [unstaged issue tracker](https://github.com/kyb3r/modmail/issues?q=is%3Aissue+is%3Aopen+-label%3Astaged) and start helping out!
Check out our [unstaged issue tracker](https://github.com/modmail-dev/modmail/issues?q=is%3Aissue+is%3Aopen+-label%3Astaged) and start helping out!

Ways to help out:
- Help out new members
Expand Down
4 changes: 2 additions & 2 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
version: "1"
rules:
- base: master
upstream: kyb3r:master
upstream: modmail-dev:master
mergeMethod: hardreset
- base: development
upstream: kyb3r:development
upstream: modmail-dev:development
mergeMethod: hardreset
9 changes: 4 additions & 5 deletions .github/workflows/lints.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,17 @@ on: [push, pull_request]

jobs:
code-style:
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ['3.8', '3.9', '3.10']
python-version: ['3.9', '3.10']

name: Python ${{ matrix.python-version }} on ${{ matrix.os }}
name: Python ${{ matrix.python-version }} on ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v3
uses: actions/setup-python@v4
with:
python-version: ${{ matrix.python-version }}
architecture: x64
Expand Down
236 changes: 122 additions & 114 deletions CHANGELOG.md

Large diffs are not rendered by default.

48 changes: 24 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@

<br>

<a href="https://heroku.com/deploy?template=https://github.com/kyb3r/modmail">
<a href="https://heroku.com/deploy?template=https://github.com/modmail-dev/modmail">
<img src="https://img.shields.io/badge/deploy_to-heroku-997FBC.svg?style=for-the-badge&logo=Heroku">
</a>

<a href="https://github.com/kyb3r/modmail/">
<a href="https://github.com/modmail-dev/modmail/">
<img src="https://api.modmail.dev/badges/instances.svg" alt="Bot instances">
</a>

<a href="https://discord.gg/j5e9p8w">
<img src="https://img.shields.io/discord/515071617815019520.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge" alt="Support">
<a href="https://discord.gg/cnUpwrnpYb">
<img src="https://img.shields.io/discord/1079074933008781362.svg?label=Discord&logo=Discord&colorB=7289da&style=for-the-badge" alt="Support">
</a>

<a href="https://patreon.com/kyber">
Expand All @@ -35,7 +35,7 @@
<img src="https://img.shields.io/badge/Code%20Style-Black-black?style=for-the-badge">
</a>

<a href="https://github.com/kyb3r/modmail/blob/master/LICENSE">
<a href="https://github.com/modmail-dev/modmail/blob/master/LICENSE">
<img src="https://img.shields.io/badge/license-agpl-e74c3c.svg?style=for-the-badge" alt="MIT License">
</a>

Expand Down Expand Up @@ -96,23 +96,23 @@ There are a few options for hosting your very own dedicated Modmail bot.

### Patreon Hosting

If you don't want the trouble of renting and configuring your server to host Modmail, we got a solution for you! We offer hosting and maintenance of your own, private Modmail bot (including a Logviewer) through [**Patreon**](https://patreon.com/kyber). Join our [Modmail Discord Server](https://discord.gg/etJNHCQ) for more info!
If you don't want the trouble of renting and configuring your server to host Modmail, we got a solution for you! We offer hosting and maintenance of your own, private Modmail bot (including a Logviewer) through [**Patreon**](https://patreon.com/kyber). Join our [Modmail Discord Server](https://discord.gg/cnUpwrnpYb) for more info!

### Local hosting (General Guide)

Modmail can be hosted on any modern hardware, including your PC. For stability and reliability, we suggest purchasing a cloud server (VPS) for under $10/mo. If you need recommendations on choosing a VPS, join our [Discord server](https://discord.gg/j5e9p8w), and we'll send you a list of non-affiliated hosting providers. Alternatively, we can host Modmail for you when you're subscribed to our [Patreon](https://patreon.com/kyber).
Modmail can be hosted on any modern hardware, including your PC. For stability and reliability, we suggest purchasing a cloud server (VPS) for under $10/mo. If you need recommendations on choosing a VPS, join our [Discord server](https://discord.gg/cnUpwrnpYb), and we'll send you a list of non-affiliated hosting providers. Alternatively, we can host Modmail for you when you're subscribed to our [Patreon](https://patreon.com/kyber).

This guide assumes you've downloaded [`Python 3.10`](https://www.python.org/downloads/release/python-376/) and added python and pip to PATH.

1. Clone this repo
```console
$ git clone https://github.com/kyb3r/modmail
$ git clone https://github.com/modmail-dev/modmail
$ cd modmail
```
2. Create a Discord bot account, grant the necessary intents, and invite the bot ([guide](https://github.com/kyb3r/modmail/wiki/Installation#2-discord-bot-account))
3. Create a free MongoDB database ([guide](https://github.com/kyb3r/modmail/wiki/Installation-(cont.)#3-create-a-database), follow it carefully!)
2. Create a Discord bot account, grant the necessary intents, and invite the bot ([guide](https://github.com/modmail-dev/modmail/wiki/Installation#2-discord-bot-account))
3. Create a free MongoDB database ([guide](https://github.com/modmail-dev/modmail/wiki/Installation-(cont.)#3-create-a-database), follow it carefully!)
4. Rename the file `.env.example` to `.env` and fill it with appropriate values
- If you can't find `.env.example` because it's hidden, create a new text file named `.env`, then copy the contents of [this file](https://raw.githubusercontent.com/kyb3r/modmail/master/.env.example) and replace the placeholders with their values
- If you can't find `.env.example` because it's hidden, create a new text file named `.env`, then copy the contents of [this file](https://raw.githubusercontent.com/modmail-dev/modmail/master/.env.example) and replace the placeholders with their values
- If you're on Windows and cannot save the file as `.env`, save it as `.env.` instead (this only applies to Windows!)
- If you do not have a Logviewer yet, leave the `LOG_URL` field as-is
5. Update pip, install pipenv, and install dependencies using pipenv
Expand All @@ -125,16 +125,16 @@ This guide assumes you've downloaded [`Python 3.10`](https://www.python.org/down
```console
$ pipenv run bot
```
7. Set up the Logviewer, see the [Logviewer installation guide](https://github.com/kyb3r/logviewer)
7. Set up the Logviewer, see the [Logviewer installation guide](https://github.com/modmail-dev/logviewer)

### Local Hosting (Docker)

We provide support for Docker to simplify the deployment of Modmail and Logviewer.
We assume you already have Docker and Docker Compose Plugin installed, if not, see [here](https://docs.docker.com/get-docker/).

1. Create a Discord bot account, grant the necessary intents, and invite the bot ([guide](https://github.com/kyb3r/modmail/wiki/Installation#2-discord-bot-account))
2. Create a file named `.env`, then copy the contents of [this file](https://raw.githubusercontent.com/kyb3r/modmail/master/.env.example) and replace the placeholders with their values
3. Create a file named `docker-compose.yml`, then copy the contents of [this file](https://raw.githubusercontent.com/kyb3r/modmail/master/docker-compose.yml), do not change anything!
1. Create a Discord bot account, grant the necessary intents, and invite the bot ([guide](https://github.com/modmail-dev/modmail/wiki/Installation#2-discord-bot-account))
2. Create a file named `.env`, then copy the contents of [this file](https://raw.githubusercontent.com/modmail-dev/modmail/master/.env.example) and replace the placeholders with their values
3. Create a file named `docker-compose.yml`, then copy the contents of [this file](https://raw.githubusercontent.com/modmail-dev/modmail/master/docker-compose.yml), do not change anything!
4. Start the bot
```console
$ docker compose up -d
Expand All @@ -147,22 +147,22 @@ Our Docker images are hosted on [GitHub Container Registry](ghcr.io), you can bu
$ docker build --tag=modmail:master .
```

Then simply remove `ghcr.io/kyb3r/` from the `docker-compose.yml` file.
Then simply remove `ghcr.io/modmail-dev/` from the `docker-compose.yml` file.

### Local Hosting (OS-Specific)

This guide is a WIP. Join our [Discord server](https://discord.gg/j5e9p8w) for more info.
This guide is a WIP. Join our [Discord server](https://discord.gg/cnUpwrnpYb) for more info.

### Platform as a Service (PaaS)

You can host this bot on Heroku (no longer free).

Installation via Heroku is possible with your web browser alone.
The [**installation guide**](https://github.com/kyb3r/modmail/wiki/Installation) (which includes a video tutorial!) will guide you through the entire installation process. If you run into any problems, join our [Modmail Discord Server](https://discord.gg/etJNHCQ) for help and support.
The [**installation guide**](https://github.com/modmail-dev/modmail/wiki/Installation) (which includes a video tutorial!) will guide you through the entire installation process. If you run into any problems, join our [Modmail Discord Server](https://discord.gg/cnUpwrnpYb) for help and support.

When using Heroku, you can configure automatic updates:
- Login to [GitHub](https://github.com/) and verify your account.
- [Fork the repo](https://github.com/kyb3r/modmail/fork).
- [Fork the repo](https://github.com/modmail-dev/modmail/fork).
- Install the [Pull app](https://github.com/apps/pull) for your fork.
- Then go to the Deploy tab in your [Heroku account](https://dashboard.heroku.com/apps) of your bot app, select GitHub and connect your fork (usually by typing "Modmail").
- Turn on auto-deploy for the `master` branch.
Expand Down Expand Up @@ -213,20 +213,20 @@ Become a sponsor on [Patreon](https://patreon.com/kyber).
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 or visit the [Unofficial List of Plugins](https://github.com/kyb3r/modmail/wiki/Unofficial-List-of-Plugins) for a list of plugins contributed by the community.
You can find a list of third-party plugins using the `?plugins registry` command or visit the [Unofficial List of Plugins](https://github.com/modmail-dev/modmail/wiki/Unofficial-List-of-Plugins) for a list of plugins contributed by the community.

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

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

## Contributing

Contributions to Modmail are always welcome, whether it be improvements to the documentation or new functionality, please feel free to make the change. Check out our [contributing guidelines](https://github.com/kyb3r/modmail/blob/master/.github/CONTRIBUTING.md) before you get started.
Contributions to Modmail are always welcome, whether it be improvements to the documentation or new functionality, please feel free to make the change. Check out our [contributing guidelines](https://github.com/modmail-dev/modmail/blob/master/.github/CONTRIBUTING.md) before you get started.

If you like this project and would like to show your appreciation, support us on **[Patreon](https://www.patreon.com/kyber)**!

## Beta Testing

Our [development](https://github.com/kyb3r/modmail/tree/development) branch is where most of our features are tested before public release. Be warned that there could be bugs in various commands so keep it away from any large servers you manage.
Our [development](https://github.com/modmail-dev/modmail/tree/development) branch is where most of our features are tested before public release. Be warned that there could be bugs in various commands so keep it away from any large servers you manage.

If you wish to test the new features and play around with them, feel free to join our [Public Test Server](https://discord.gg/v5hTjKC). Bugs can be raised within that server or in our Github issues (state that you are using the development branch though).
12 changes: 6 additions & 6 deletions app.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "Modmail",
"description": "An easy to install Modmail bot for Discord - DM to contact mods!",
"repository": "https://github.com/kyb3r/modmail",
"repository": "https://github.com/modmail-dev/modmail",
"env": {
"TOKEN": {
"description": "Your discord bot's token.",
Expand All @@ -11,10 +11,6 @@
"description": "The id for the server you are hosting this bot for.",
"required": true
},
"MODMAIL_GUILD_ID": {
"description": "The ID of the discord server where the threads channels should be created (receiving server). Default to GUILD_ID.",
"required": false
},
"OWNERS": {
"description": "Comma separated user IDs of people that are allowed to use owner only commands. (eval).",
"required": true
Expand All @@ -34,6 +30,10 @@
"GITHUB_TOKEN": {
"description": "A github personal access token with the repo scope.",
"required": false
},
"REGISTRY_PLUGINS_ONLY": {
"description": "If set to true, only plugins that are in the registry can be loaded.",
"required": false
}
}
}
}
16 changes: 10 additions & 6 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,12 +90,16 @@ def __init__(self):
self.plugin_db = PluginDatabaseClient(self) # Deprecated
self.startup()

def get_guild_icon(self, guild: typing.Optional[discord.Guild]) -> str:
def get_guild_icon(
self, guild: typing.Optional[discord.Guild], *, size: typing.Optional[int] = None
) -> str:
if guild is None:
guild = self.guild
if guild.icon is None:
return "https://cdn.discordapp.com/embed/avatars/0.png"
return guild.icon.url
if size is None:
return guild.icon.url
return guild.icon.with_size(size).url

def _resolve_snippet(self, name: str) -> typing.Optional[str]:
"""
Expand Down Expand Up @@ -888,7 +892,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
return
sent_emoji, blocked_emoji = await self.retrieve_emoji()

if message.type != discord.MessageType.default:
if message.type not in [discord.MessageType.default, discord.MessageType.reply]:
return

thread = await self.threads.find(recipient=message.author)
Expand All @@ -912,7 +916,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
)
embed.set_footer(
text=self.config["disabled_new_thread_footer"],
icon_url=self.get_guild_icon(guild=message.guild),
icon_url=self.get_guild_icon(guild=message.guild, size=128),
)
logger.info("A new thread was blocked from %s due to disabled Modmail.", message.author)
await self.add_reaction(message, blocked_emoji)
Expand All @@ -928,7 +932,7 @@ async def process_dm_modmail(self, message: discord.Message) -> None:
)
embed.set_footer(
text=self.config["disabled_current_thread_footer"],
icon_url=self.get_guild_icon(guild=message.guild),
icon_url=self.get_guild_icon(guild=message.guild, size=128),
)
logger.info("A message was blocked from %s due to disabled Modmail.", message.author)
await self.add_reaction(message, blocked_emoji)
Expand Down Expand Up @@ -1335,7 +1339,7 @@ async def handle_react_to_contact(self, payload):
)
embed.set_footer(
text=self.config["disabled_new_thread_footer"],
icon_url=self.get_guild_icon(guild=channel.guild),
icon_url=self.get_guild_icon(guild=channel.guild, size=128),
)
logger.info(
"A new thread using react to contact was blocked from %s due to disabled Modmail.",
Expand Down
10 changes: 5 additions & 5 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ async def setup(self, ctx):
embed.add_field(
name="Thanks for using our bot!",
value="If you like what you see, consider giving the "
"[repo a star](https://github.com/kyb3r/modmail) :star: and if you are "
"[repo a star](https://github.com/modmail-dev/modmail) :star: and if you are "
"feeling extra generous, buy us coffee on [Patreon](https://patreon.com/kyber) :heart:!",
)

Expand Down Expand Up @@ -160,15 +160,15 @@ async def snippet(self, ctx, *, name: str.lower = None):
color=self.bot.error_color, description="You dont have any snippets at the moment."
)
embed.set_footer(text=f'Check "{self.bot.prefix}help snippet add" to add a snippet.')
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
return await ctx.send(embed=embed)

embeds = []

for i, names in enumerate(zip_longest(*(iter(sorted(self.bot.snippets)),) * 15)):
description = format_description(i, names)
embed = discord.Embed(color=self.bot.main_color, description=description)
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild))
embed.set_author(name="Snippets", icon_url=self.bot.get_guild_icon(guild=ctx.guild, size=128))
embeds.append(embed)

session = EmbedPaginatorSession(ctx, *embeds)
Expand Down Expand Up @@ -1031,7 +1031,7 @@ async def anonadduser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
name = tag
avatar_url = self.bot.config["anon_avatar_url"]
if avatar_url is None:
avatar_url = self.bot.get_guild_icon(guild=ctx.guild)
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)
em.set_footer(text=name, icon_url=avatar_url)

for u in users:
Expand Down Expand Up @@ -1120,7 +1120,7 @@ async def anonremoveuser(self, ctx, *users_arg: Union[discord.Member, discord.Ro
name = tag
avatar_url = self.bot.config["anon_avatar_url"]
if avatar_url is None:
avatar_url = self.bot.get_guild_icon(guild=ctx.guild)
avatar_url = self.bot.get_guild_icon(guild=ctx.guild, size=128)
em.set_footer(text=name, icon_url=avatar_url)

for u in users:
Expand Down
Loading

0 comments on commit ecee83d

Please sign in to comment.