Skip to content

Commit d2d1d3d

Browse files
authored
Merge branch 'development' into snippets-preview
2 parents 6833fa1 + 57ac0f1 commit d2d1d3d

File tree

10 files changed

+129
-43
lines changed

10 files changed

+129
-43
lines changed

CHANGELOG.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
66
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
77
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/modmail-dev/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.
88

9+
# v4.1.1
10+
11+
### Fixed
12+
- `?msglink` now supports threads with multiple recipients. ([PR #3341](https://github.com/modmail-dev/Modmail/pull/3341))
13+
- Fixed persistent notes not working due to discord.py internal change. ([PR #3324](https://github.com/modmail-dev/Modmail/pull/3324))
14+
15+
### Added
16+
- Support for custom activities with `?activity custom <text>` ([PR #3352](https://github.com/modmail-dev/Modmail/pull/3352))
17+
918
# v4.1.0
1019

1120
Drops support for Python 3.9. Python 3.10 and Python 3.11 are now the only supported versions.
@@ -14,7 +23,7 @@ Drops support for Python 3.9. Python 3.10 and Python 3.11 are now the only suppo
1423
- GIF stickers no longer cause the bot to crash.
1524
- `?alias make/create` as aliases to `?alias add`. This improves continuity between the bot and its command structure. ([PR #3195](https://github.com/kyb3r/modmail/pull/3195))
1625
- Loading the blocked list with the `?blocked` command takes a long time when the list is large. ([PR #3242](https://github.com/kyb3r/modmail/pull/3242))
17-
- Reply not being forwarded from DM. (PR [#3239](https://github.com/modmail-dev/modmail/pull/3239))
26+
- Reply not being forwarded from DM. ([PR #3239](https://github.com/modmail-dev/modmail/pull/3239))
1827
- Cleanup imports after removing/unloading a plugin. ([PR #3226](https://github.com/modmail-dev/Modmail/pull/3226))
1928
- Fixed a syntactic error in the close message when a thread is closed after a certain duration. ([PR #3233](https://github.com/modmail-dev/Modmail/pull/3233))
2029
- Removed an extra space in the help command title when the command has no parameters. ([PR #3271](https://github.com/modmail-dev/Modmail/pull/3271))

Dockerfile

Lines changed: 30 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,38 @@
1-
FROM python:3.10 as py
1+
FROM python:3.11-slim-bookworm as base
22

3-
FROM py as build
3+
RUN apt-get update && \
4+
apt-get install --no-install-recommends -y \
5+
# Install CairoSVG dependencies.
6+
libcairo2 && \
7+
# Cleanup APT.
8+
apt-get clean && \
9+
rm -rf /var/lib/apt/lists/* && \
10+
# Create a non-root user.
11+
useradd --shell /usr/sbin/nologin --create-home -d /opt/modmail modmail
412

5-
RUN apt update && apt install -y g++ git
13+
FROM base as builder
614

7-
COPY requirements.txt /
8-
RUN pip install --prefix=/inst -U -r /requirements.txt
15+
COPY requirements.txt .
916

10-
FROM py
17+
RUN pip install --root-user-action=ignore --no-cache-dir --upgrade pip wheel && \
18+
python -m venv /opt/modmail/.venv && \
19+
. /opt/modmail/.venv/bin/activate && \
20+
pip install --no-cache-dir --upgrade -r requirements.txt
1121

12-
COPY --from=build /inst /usr/local
22+
FROM base
1323

14-
ENV USING_DOCKER yes
15-
RUN useradd --system --no-create-home modmail
16-
USER modmail
24+
# Copy the entire venv.
25+
COPY --from=builder --chown=modmail:modmail /opt/modmail/.venv /opt/modmail/.venv
26+
27+
# Copy repository files.
28+
WORKDIR /opt/modmail
29+
USER modmail:modmail
30+
COPY --chown=modmail:modmail . .
31+
32+
# This sets some Python runtime variables and disables the internal auto-update.
33+
ENV PYTHONUNBUFFERED=1 \
34+
PYTHONDONTWRITEBYTECODE=1 \
35+
PATH=/opt/modmail/.venv/bin:$PATH \
36+
USING_DOCKER=yes
1737

18-
WORKDIR /modmailbot
1938
CMD ["python", "bot.py"]
20-
COPY --chown=modmail:modmail . /modmailbot

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,13 @@ Advertise Your Server:
147147
</a>
148148
<br>
149149
<br>
150+
Help Us • Help Other's:
151+
<br>
152+
<a href='https://discord.gg/5yQCFzY6HU'>
153+
<img height=100 src='https://i.imgur.com/Gi3jxeH.gif' style='margin:5px'>
154+
</a>
155+
<br>
156+
<br>
150157
Discord Advice Center:
151158
<br>
152159
<a href='https://discord.gg/zmwZy5fd9v'>

SPONSORS.json

Lines changed: 48 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@
8181
"icon_url": "https://i.imgur.com/cjVtRw5.jpg"
8282
},
8383
"image": {
84-
"url": "https://i.imgur.com/1hrjcHd.png"
84+
"url": "https://i.imgur.com/1hrjcHd.png"
8585
},
8686
"fields": [
8787
{
@@ -91,23 +91,6 @@
9191
]
9292
}
9393
},
94-
{
95-
"embed": {
96-
"title": "Advertise Your Server",
97-
"description": "Advertise Your Server is the leading advertising and growth Discord Server. With over 60,000 members we can help grow your community with our range of services.\n\n__**Advertise Your Server offers everything you need to grow and find servers:**__\n\n:chart_with_upwards_trend: **Discord Growth Experts** to give you advice on how to __grow your server.__ (server/advert reviews, growth tips)\n:dividers: Over 40 different channels for **different server categories.**\n:robot: Our own __custom__ **bump bot.** (Liam)\n:bar_chart: Currently the __BIGGEST__ advertising server on Discord.\n:computer: Our own server __Listing Site__!\n:ticket: Small Servers Program for servers with less than 300 members.\n:dvd: Weekly Podcast, Blog, Email Newsletter and YouTube Tutorials. \n\nhttps://discord.gg/zP8KcF4VQz\nhttps://aysdiscord.com",
98-
"author": {
99-
"name": "Advertise Your Server",
100-
"icon_url": "https://cdn.discordapp.com/attachments/563522692418895872/907067815486427176/logo4.png"
101-
},
102-
"color": 431075,
103-
"footer": {
104-
"text": "Grow Your Discord Server"
105-
},
106-
"image": {
107-
"url": "https://cdn.discordapp.com/attachments/472811257913933834/907068966311166043/unknown_2.png"
108-
}
109-
}
110-
},
11194
{
11295
"embed": {
11396
"footer": {
@@ -128,5 +111,52 @@
128111
"url": "https://discord.gg/uncommon",
129112
"title": "uncommon community"
130113
}
114+
},
115+
{
116+
"embed": {
117+
"author": {
118+
"name": "Help us • Help Others"
119+
},
120+
"title": "Join Today",
121+
"url": "https://discord.gg/5yQCFzY6HU",
122+
"description": "At Help Us • Help Others, we accept as true with inside the transformative electricity of cooperation and kindness. Each one people has the capability to make a meaningful impact by means of helping and caring for others. Whether you want assistance or want to offer it, this is the right region for you!",
123+
"fields": [
124+
{
125+
"name": "What we offer:",
126+
"value": "`🎬` - Active community\n`👮` - Active staff around the globe! \n`🛜` - 40+ Advertising channels to grow your socials!\n`💎` - Boosting Perks\n`🎉` - Event's monthly especially bank holiday roles!!\n`🔢` - Unique levelling systems\n`📞` - Multiple voice channels including gaming!\n`🎁` - Exclusive giveaways!"
127+
},
128+
{
129+
"name": "We Are Hiring",
130+
"value": "`🔵` - Moderators\n`🔵` - Human Resources\n`🔵` - Community Team\n`🔵` - Partnership Manager\n`🔵` - Growth Manager\n`🚀` Much more to come!\n\n\nJoin Today!"
131+
}
132+
],
133+
"image": {
134+
"url": "https://cdn.discordapp.com/attachments/1218338794416246874/1243635366326567002/AD_animated.gif"
135+
},
136+
"color": 45300,
137+
"footer": {
138+
"text": "Help Us • Help Others"
139+
}
140+
}
141+
},
142+
{
143+
"embed": {
144+
"description": "> Be apart of our community as we start to grow! and embark on a long journey.\n——————————————————-\n**What we offer?**\n\n➺〚🖌️〛Custom Liveries \n➺〚❤️〛Friendly and Growing community.\n➺〚🤝〛Partnerships.\n➺〚🎮〛Daily SSUs. \n➺〚🚨〛Great roleplays.\n➺〚💬〛Kind and Professional staff\n➺〚🎉〛Giveaways!!! \n——————————————————-\n**Emergency Services**\n\n➺〚🚔〛NY Police Force\n➺〚🚒〛Fire & Emergency NY\n➺〚🚧〛NY department of transportation \n\n——————————————————-\n**Whitelisted**\nComing soon!\n——————————————————-\n**What are we looking for!**\n\n➺〚💬〛More members\n➺〚⭐〛Staff Members - **WE'RE HIRING!**\n➺〚🤝〛Partnerships\n➺〚💎〛Boosters\n——————————————————\n\n**[Join now](https://discord.com/invite/qt62qSnKVa)**",
145+
"author": {
146+
"name": "New York Roleplay",
147+
"icon_url": "https://cdn.discordapp.com/icons/1172553254882775111/648d5bc50393a21216527a1aaa61286d.webp"
148+
},
149+
"color": 431075,
150+
"thumbnail": {
151+
"url": "https://cdn.discordapp.com/icons/1172553254882775111/648d5bc50393a21216527a1aaa61286d.webp"
152+
}
153+
}
154+
},
155+
{
156+
"embed": {
157+
"title": "CityStore PLC",
158+
"description": "*Your Retail Journey*\n*\"Better choice and better value in food, fashion & homewares.\"*\n\n\n**------------------------------------------**\n*__About us__*\nSupermarket, CityStore PLC! Attend a training to become staff!\n\nThis game is currently in V3\n\nWe have a training Centre and applications center!\n\n**------------------------------------------**\n\n> *❤️ Don't hesitate! Dive into the excitement today by joining our vibrant community on Discord. Experience our unique perspective and become an integral part of our group. Your **journey** with us promises to be unforgettable no regrets, only great memories await! ❤️*\n\n*We hope to see you. *\n\n*Signed,*\n**CityStore PLC**\n> Discord: https://discord.gg/yjFQb5mrSk\n> Roblox Group: https://www.roblox.com/groups/32819373/CityStore-PLC#!/about\n\nJoin us now and become apart of Citystore PLC community! 🎉",
159+
"color": 15523550
160+
}
131161
}
132162
]

bot.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = "4.1.0"
1+
__version__ = "4.1.1"
22

33

44
import asyncio

cogs/modmail.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -712,9 +712,15 @@ async def sfw(self, ctx):
712712
@checks.thread_only()
713713
async def msglink(self, ctx, message_id: int):
714714
"""Retrieves the link to a message in the current thread."""
715-
try:
716-
message = await ctx.thread.recipient.fetch_message(message_id)
717-
except discord.NotFound:
715+
found = False
716+
for recipient in ctx.thread.recipients:
717+
try:
718+
message = await recipient.fetch_message(message_id)
719+
found = True
720+
break
721+
except discord.NotFound:
722+
continue
723+
if not found:
718724
embed = discord.Embed(
719725
color=self.bot.error_color, description="Message not found or no longer exists."
720726
)

cogs/plugins.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,21 @@
66
import sys
77
import typing
88
import zipfile
9-
from importlib import invalidate_caches
109
from difflib import get_close_matches
10+
from importlib import invalidate_caches
1111
from pathlib import Path, PurePath
1212
from re import match
1313
from site import USER_SITE
1414
from subprocess import PIPE
1515

1616
import discord
1717
from discord.ext import commands
18-
1918
from packaging.version import Version
2019

2120
from core import checks
2221
from core.models import PermissionLevel, getLogger
2322
from core.paginator import EmbedPaginatorSession
24-
from core.utils import truncate, trigger_typing
23+
from core.utils import trigger_typing, truncate
2524

2625
logger = getLogger(__name__)
2726

@@ -132,8 +131,11 @@ async def cog_load(self):
132131

133132
async def populate_registry(self):
134133
url = "https://raw.githubusercontent.com/modmail-dev/modmail/master/plugins/registry.json"
135-
async with self.bot.session.get(url) as resp:
136-
self.registry = json.loads(await resp.text())
134+
try:
135+
async with self.bot.session.get(url) as resp:
136+
self.registry = json.loads(await resp.text())
137+
except asyncio.TimeoutError:
138+
logger.warning("Failed to fetch registry. Loading with empty registry")
137139

138140
async def initial_load_plugins(self):
139141
for plugin_name in list(self.bot.config["plugins"]):
@@ -638,6 +640,14 @@ async def plugins_registry(self, ctx, *, plugin_name: typing.Union[int, str] = N
638640

639641
registry = sorted(self.registry.items(), key=lambda elem: elem[0])
640642

643+
if not registry:
644+
embed = discord.Embed(
645+
color=self.bot.error_color,
646+
description="Registry is empty. This could be because it failed to load.",
647+
)
648+
await ctx.send(embed=embed)
649+
return
650+
641651
if isinstance(plugin_name, int):
642652
index = plugin_name - 1
643653
if index < 0:

cogs/utility.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,7 @@ async def activity(self, ctx, activity_type: str.lower, *, message: str = ""):
499499
- `listening`
500500
- `watching`
501501
- `competing`
502+
- `custom`
502503
503504
When activity type is set to `listening`,
504505
it must be followed by a "to": "listening to..."
@@ -510,6 +511,9 @@ async def activity(self, ctx, activity_type: str.lower, *, message: str = ""):
510511
the linked twitch page:
511512
- `{prefix}config set twitch_url https://www.twitch.tv/somechannel/`
512513
514+
When activity type is set to `custom`, you can set
515+
any custom text as the activity message.
516+
513517
To remove the current activity status:
514518
- `{prefix}activity clear`
515519
"""
@@ -609,7 +613,9 @@ async def set_presence(self, *, status=None, activity_type=None, activity_messag
609613
elif activity_type == ActivityType.streaming:
610614
url = self.bot.config["twitch_url"]
611615

612-
if activity_type is not None:
616+
if activity_type == ActivityType.custom:
617+
activity = discord.CustomActivity(name=activity_message)
618+
elif activity_type is not None:
613619
activity = discord.Activity(type=activity_type, name=activity_message, url=url)
614620
else:
615621
activity = None

core/thread.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ async def send_persistent_notes():
250250
ids = {}
251251

252252
class State:
253-
def store_user(self, user):
253+
def store_user(self, user, cache):
254254
return user
255255

256256
for note in notes:

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ extend-exclude = '''
2121

2222
[tool.poetry]
2323
name = 'Modmail'
24-
version = '4.1.0'
24+
version = '4.1.1'
2525
description = "Modmail is similar to Reddit's Modmail, both in functionality and purpose. It serves as a shared inbox for server staff to communicate with their users in a seamless way."
2626
license = 'AGPL-3.0-only'
2727
authors = [

0 commit comments

Comments
 (0)