Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions .github/pull.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "1"
rules:
- base: master
upstream: kyb3r:master
mergeMethod: hardreset
- base: development
upstream: kyb3r:development
mergeMethod: hardreset
2 changes: 1 addition & 1 deletion .pylintrc
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ignore-patterns=

# Use multiple processes to speed up Pylint. Specifying 0 will auto-detect the
# number of processors available to use.
jobs=1
jobs=0

# Control the amount of potential inferred values when inferring a single
# object. This can help the performance when dealing with large functions or
Expand Down
10 changes: 7 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ however, insignificant breaking changes does not guarantee a major version bump,

- `disable_recipient_thread_close` is removed, a new configuration variable `recipient_thread_close` replaces it which defaults to False.
- Truthy and falsy values for binary configuration variables are now interpreted respectfully.
- `LOG_URL_PREFIX` cannot be set to "NONE" to specify no additional path in the future, "/" is the new method.

### Added

Expand All @@ -25,6 +26,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
- `?help` works for alias and snippets.
- `?config help <config-name>` shows a help embed for the configuration.
- Support setting permissions for sub commands.
- Support numbers (1-5) as substitutes for Permission Level REGULAR - OWNER in `?perms` sub commands.

### Changes

Expand All @@ -37,6 +39,7 @@ however, insignificant breaking changes does not guarantee a major version bump,
- `?plugin registry page-number` plugin registry can specify a page number for quick access.
- A reworked interface for `?snippet` and `?alias`.
- Add an `?snippet raw <name>` command for viewing the raw content of a snippet (escaped markdown).
- Add an `?alias raw <name>` command for viewing the raw content of a alias (escaped markdown).
- The placeholder channel for the streaming status changed to https://www.twitch.tv/discordmodmail/.
- Removed unclear `rm` alias for some `remove` commands.
- Paginate `?config options`.
Expand All @@ -63,7 +66,8 @@ however, insignificant breaking changes does not guarantee a major version bump,
- Use discord tasks for metadata loop.
- More debug based logging.
- Reduce redundancies in `?perms` sub commands.

- paginator been split into `EmbedPaginatorSession` and `MessagePaginatorSession`, both subclassing `PaginatorSession`.

# v3.0.3

### Added
Expand Down Expand Up @@ -225,7 +229,7 @@ Un-deprecated the `OWNERS` config variable to support discord developer team acc
### New Permissions System

- A brand new permission system! Replacing the old guild-based permissions (ie. manage channels, manage messages), the new system enables you to customize your desired permission level specific to a command or a group of commands for a role or user.
- There are five permission groups/levels:
- There are five permission levels:
- Owner [5]
- Administrator [4]
- Moderator [3]
Expand All @@ -247,7 +251,7 @@ The same applies to individual commands permissions:

To revoke permission, use `remove` instead of `add`.

To view all roles and users with permission for a permission group or command do:
To view all roles and users with permission for a permission level or command do:
- `?permissions get command command-name`
- `?permissions get level owner`

Expand Down
10 changes: 6 additions & 4 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
FROM kennethreitz/pipenv
FROM library/python:latest
RUN apt update && apt install -y pipenv
RUN mkdir -p /bot && cd /bot && git clone https://github.com/kyb3r/modmail .
WORKDIR /bot
RUN pipenv install

COPY . /app

CMD python3 bot.py
CMD ["pipenv", "run", "bot"]
10 changes: 0 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,20 +112,10 @@ $ pipenv run bot

Special thanks to our sponsors for supporting the project.

- [flyAurora](https://flyaurora.xyz/):

<a href='https://www.youtube.com/channel/UCgSmBJD9imASmJRleycTCwQ/featured'>
<img height=150 src='https://i.imgur.com/WyzaPKY.png' style='margin:10'>
</a>

<a href='https://flyaurora.xyz/'>
<img height=150 src='https://pbs.twimg.com/profile_images/1142307497115443200/whbHhb9B_400x400.jpg'>
</a>
<br>
<br>



Become a [sponsor](https://patreon.com/kyber).

## Plugins
Expand Down
4 changes: 0 additions & 4 deletions app.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"description": "Comma separated user IDs of people that are allowed to use owner only commands. (eval and update).",
"required": true
},
"GITHUB_ACCESS_TOKEN": {
"description": "Your personal access token for GitHub, adding this gives you the ability to use the 'update' command, which will sync your fork with the main repo.",
"required": false
},
"MONGO_URI": {
"description": "Mongo DB connection URI for self-hosting your data.",
"required": true
Expand Down
39 changes: 17 additions & 22 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import asyncio
import logging
from datetime import datetime
from itertools import zip_longest, takewhile
from itertools import zip_longest
from typing import Optional, Union
from types import SimpleNamespace as param

Expand All @@ -15,9 +15,9 @@
from core import checks
from core.decorators import trigger_typing
from core.models import PermissionLevel
from core.paginator import PaginatorSession
from core.paginator import EmbedPaginatorSession
from core.time import UserFriendlyTime, human_timedelta
from core.utils import format_preview, User, create_not_found_embed
from core.utils import format_preview, User, create_not_found_embed, format_description

logger = logging.getLogger("Modmail")

Expand Down Expand Up @@ -87,7 +87,7 @@ async def setup(self, ctx):
await self.bot.config.update()
await ctx.send(
"Successfully set up server.\n"
"Consider setting permission groups to give access "
"Consider setting permission levels to give access "
"to roles or users the ability to use Modmail.\n"
f"Type `{self.bot.prefix}permissions` for more info."
)
Expand Down Expand Up @@ -117,7 +117,7 @@ async def snippet(self, ctx, *, name: str.lower = None):
with `{prefix}snippet-name`, the message "A pre-defined text."
will be sent to the recipient.

Currently, there is not a default anonymous snippet command; however, a workaround
Currently, there is not a built-in anonymous snippet command; however, a workaround
is available using `{prefix}alias`. Here is how:
- `{prefix}alias add snippet-name anonreply A pre-defined anonymous text.`

Expand Down Expand Up @@ -149,22 +149,20 @@ async def snippet(self, ctx, *, name: str.lower = None):
for i, names in enumerate(
zip_longest(*(iter(sorted(self.bot.snippets)),) * 15)
):
description = "\n".join(
": ".join((str(a + i * 15), b))
for a, b in enumerate(
takewhile(lambda x: x is not None, names), start=1
)
)
description = format_description(i, names)
embed = discord.Embed(color=self.bot.main_color, description=description)
embed.set_author(name="Snippets", icon_url=ctx.guild.icon_url)
embeds.append(embed)

session = PaginatorSession(ctx, *embeds)
session = EmbedPaginatorSession(ctx, *embeds)
await session.run()

@snippet.command(name="raw")
@checks.has_permissions(PermissionLevel.SUPPORTER)
async def snippet_raw(self, ctx, *, name: str.lower):
"""
View the raw content of a snippet.
"""
val = self.bot.snippets.get(name)
if val is None:
embed = create_not_found_embed(name, self.bot.snippets.keys(), "Snippet")
Expand Down Expand Up @@ -567,16 +565,12 @@ def format_log_embeds(self, logs, avatar_url):
title = f"Total Results Found ({len(logs)})"

for entry in logs:

key = entry["key"]

created_at = parser.parse(entry["created_at"])

prefix = self.bot.config["log_url_prefix"]
prefix = self.bot.config["log_url_prefix"].strip("/")
if prefix == "NONE":
prefix = ""

log_url = self.bot.config["log_url"].strip("/") + f"{prefix}/{key}"
log_url = f"{self.bot.config['log_url'].strip('/')}{'/' + prefix if prefix else ''}/{entry['key']}"

username = entry["recipient"]["name"] + "#"
username += entry["recipient"]["discriminator"]
Expand Down Expand Up @@ -637,7 +631,7 @@ async def logs(self, ctx, *, user: User = None):

embeds = self.format_log_embeds(logs, avatar_url=icon_url)

session = PaginatorSession(ctx, *embeds)
session = EmbedPaginatorSession(ctx, *embeds)
await session.run()

@logs.command(name="closed-by", aliases=["closeby"])
Expand Down Expand Up @@ -670,7 +664,7 @@ async def logs_closed_by(self, ctx, *, user: User = None):
)
return await ctx.send(embed=embed)

session = PaginatorSession(ctx, *embeds)
session = EmbedPaginatorSession(ctx, *embeds)
await session.run()

@logs.command(name="search", aliases=["find"])
Expand Down Expand Up @@ -703,7 +697,7 @@ async def logs_search(self, ctx, limit: Optional[int] = None, *, query):
)
return await ctx.send(embed=embed)

session = PaginatorSession(ctx, *embeds)
session = EmbedPaginatorSession(ctx, *embeds)
await session.run()

@commands.command()
Expand Down Expand Up @@ -899,7 +893,8 @@ async def blocked(self, ctx):
else:
embeds[-1].description = "Currently there are no blocked users."

await PaginatorSession(ctx, *embeds).run()
session = EmbedPaginatorSession(ctx, *embeds)
await session.run()

@blocked.command(name="whitelist")
@checks.has_permissions(PermissionLevel.MODERATOR)
Expand Down
8 changes: 4 additions & 4 deletions cogs/plugins.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

from core import checks
from core.models import PermissionLevel
from core.paginator import PaginatorSession
from core.paginator import EmbedPaginatorSession

logger = logging.getLogger("Modmail")

Expand Down Expand Up @@ -288,7 +288,7 @@ async def plugin_remove(self, ctx, *, plugin_name: str):
for i in self.bot.config["plugins"]
):
# if there are no more of such repos, delete the folder
def onerror(func, path, exc_info): # pylint: disable=W0613
def onerror(func, path, _):
if not os.access(path, os.W_OK):
# Is the error an access error?
os.chmod(path, stat.S_IWUSR)
Expand Down Expand Up @@ -465,7 +465,7 @@ async def plugin_registry(self, ctx, *, plugin_name: typing.Union[int, str] = No

embeds.append(embed)

paginator = PaginatorSession(ctx, *embeds)
paginator = EmbedPaginatorSession(ctx, *embeds)
paginator.current = index
await paginator.run()

Expand Down Expand Up @@ -499,7 +499,7 @@ async def plugin_registry_compact(self, ctx):
embed.set_author(name="Plugin Registry", icon_url=self.bot.user.avatar_url)
embeds.append(embed)

paginator = PaginatorSession(ctx, *embeds)
paginator = EmbedPaginatorSession(ctx, *embeds)
await paginator.run()


Expand Down
Loading