Skip to content

Commit c883b76

Browse files
authored
Merge pull request #3356 from modmail-dev/development
Merge Development
2 parents bb2892f + 57ac0f1 commit c883b76

File tree

7 files changed

+44
-13
lines changed

7 files changed

+44
-13
lines changed

CHANGELOG.md

+10-1
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))

bot.py

+1-1
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

+9-3
Original file line numberDiff line numberDiff line change
@@ -696,9 +696,15 @@ async def sfw(self, ctx):
696696
@checks.thread_only()
697697
async def msglink(self, ctx, message_id: int):
698698
"""Retrieves the link to a message in the current thread."""
699-
try:
700-
message = await ctx.thread.recipient.fetch_message(message_id)
701-
except discord.NotFound:
699+
found = False
700+
for recipient in ctx.thread.recipients:
701+
try:
702+
message = await recipient.fetch_message(message_id)
703+
found = True
704+
break
705+
except discord.NotFound:
706+
continue
707+
if not found:
702708
embed = discord.Embed(
703709
color=self.bot.error_color, description="Message not found or no longer exists."
704710
)

cogs/plugins.py

+15-5
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

+7-1
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

+1-1
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

+1-1
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)