Skip to content

Commit

Permalink
New thread related config, resolves #3072
Browse files Browse the repository at this point in the history
  • Loading branch information
fourjr committed Aug 7, 2021
1 parent 68ede9d commit daf04b0
Show file tree
Hide file tree
Showing 8 changed files with 119 additions and 31 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/).
This project mostly adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html);
however, insignificant breaking changes do not guarantee a major version bump, see the reasoning [here](https://github.com/kyb3r/modmail/issues/319). If you're a plugin developer, note the "BREAKING" section.

# v3.10.0-dev5
# v3.10.0-dev6

v3.10 adds group conversations while resolving other bugs and QOL changes. It is potentially breaking to some plugins that adds functionality to threads.

Expand All @@ -20,6 +20,7 @@ v3.10 adds group conversations while resolving other bugs and QOL changes. It is
- Ability to have group conversations. ([GH #143](https://github.com/kyb3r/modmail/issues/143))
- Snippets are invoked case insensitively. ([GH #3077](https://github.com/kyb3r/modmail/issues/3077), [PR #3080](https://github.com/kyb3r/modmail/pull/3080))
- Default tags now use top hoisted role. ([GH #3014](https://github.com/kyb3r/modmail/issues/3014))
- New thread-related config - `thread_show_roles`, `thread_show_account_age`, `thread_show_join_age`, `thread_cancelled`, `thread_creation_contact_title`, `thread_creation_self_contact_response`, `thread_creation_contact_response`. ([GH #3072](https://github.com/kyb3r/modmail/issues/3072))

### Fixed

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<br>

<a href="#">
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev5-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7h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WIoVTQ2uxAk15yJg1awl7ZSCaUE82uRxhTpt1TNXq0Ip2pSobIqCc0iVoqsI0ipXr1bhywfVXxYdiA3Sourz2dqc8lbNQJz4bDWqix73E7ZjhgrKOjYmvfWLbZcZqCdTPjjHGLdtibi2U5Q6NWiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
<img src="https://img.shields.io/badge/Latest%20Version-v3.10.0-dev6-7289da?style=for-the-badge&logo=data:image/gif;base64,R0lGODlhGAAYAPcAAAAAADQ+Yj5MdThCaEFOekNQfWt5e1lqfEdVhVpriVx1iVtsnFZpll1xlF1znFx5mGNtjGR7hWNzjGd5iWJunGNslmN0lGl1lGN5lWt7lWR0nGp1nWR5nGt8nHJ9l3J9jFxto1xtqlZqqF5zpF15pV10rVx5q1Z2ql1us150s114sV50uVd1smJupGNurGN0pGp1pGR6o2t7o2F0rml0rGR5rGt8q3J9pGNus2Fvu2Bzs2p2smR5s2t7tGF0u2N6vGp7u2l1uXJ+uGJ1wWV7w2l+xWl+yl5zwHWDiWyCmHODnHiGmHSLkW2CpGuEqnSCpHqMo3ODrHWKrXyMq3iHp3yTqGyEtWqFunKDs3uLtHSGvXSMvHuMu3eItnyTs3yTu3iUuW+RsV+ApmuCxG2Dy22LxnSMxHuMxHGGzXSLzXqLzXWFxXyTw3uSy3WSx26E0W+N2m+L1XKG03SL1XmL1HOL2HmL23WF2XiS1m+QyHOK4XmL4XaH4nGM5ImXm4WOlJSjnoOOq4OOpYSUrImXqJOcqYONt4OUtIybtIOUu4ycvImYt5OcuIyiqZekqYyiupOjvJurvJimtp+yvqKruae2ua23trLCucPHvIOMxoOUxIuaw4eYyJKbyISW1YiW0o2kyJWlxJqpxZWkzJury5aoxp6xxZ2zyZio1Jyy2Yuk0aOsyKOyxKOzzKy8zKq2yLO7xqOr1KSz1Ku706W026y73Ki21bK716u75LS95KSu4Zyx6bPDzLjGx63B2LPD1LTE3LvL3brI17/S2bbKzrTE47rF47zM5L3M67bH577R5L7R67zK8rjM8MLM3MPK1sTT3crU3MjW2dLZ2srUy8PN5MTO68nP68jL48TS5MnT5cbR68jS7M3b7Mva5dTb6MTO8srO8szF8MXR8snS8c3a8cnY+NXb9tDL7dnm6dzk8tro99Pq9uTp6+r17fr77eTr/efr+Oz09OXz/Ov0/e37/uj39fX19fX89fz+9vP1/fX9/f7//vr2/ODl4sK75yH5BAEAAAAALAAAAAAYABgAAAj/AAEAmFOnoMGDCAvGmRNHYMKHEOdIhEgRIcGKGDMeTJVO00WNBj194/frFik5IOvgqdaP371N26xpefORYq57/HI+s7Vtmy0eKCmmapcz575FPXt+SfHmociiRae1SroNWIoVTQ2uxAk15yJg1awl7ZSCaUE82uRxhTpt1TNXq0Ip2pSobIqCc0iVoqsI0ipXr1bhywfVXxYdiA3Sourz2dqc8lbNQJz4bDWqix73E7ZjhgrKOjYmvfWLbZcZqCdTPjjHGLdtibi2U5Q6NWiEqqq64ifvVe3at1nX2tTuWQ/QyIMfxHOGi+rkyeMklPMDuvWaBqlbj469IPUU2ykPCOw+53t4AAEBADs=">
</a>

<br>
Expand Down
2 changes: 1 addition & 1 deletion bot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = "v3.10.0-dev5"
__version__ = "v3.10.0-dev6"


import asyncio
Expand Down
16 changes: 9 additions & 7 deletions cogs/modmail.py
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str

if not silent:
description = self.bot.formatter.format(
self.bot.config["private_added_to_group_description"], moderator=ctx.author
self.bot.config["private_added_to_group_response"], moderator=ctx.author
)
em = discord.Embed(
title=self.bot.config["private_added_to_group_title"],
Expand All @@ -734,7 +734,7 @@ async def adduser(self, ctx, *users_arg: Union[discord.Member, discord.Role, str
await u.send(embed=em)

description = self.bot.formatter.format(
self.bot.config["public_added_to_group_description"],
self.bot.config["public_added_to_group_response"],
moderator=ctx.author,
users=", ".join(u.name for u in users),
)
Expand Down Expand Up @@ -799,7 +799,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,

if not silent:
description = self.bot.formatter.format(
self.bot.config["private_removed_from_group_description"], moderator=ctx.author
self.bot.config["private_removed_from_group_response"], moderator=ctx.author
)
em = discord.Embed(
title=self.bot.config["private_removed_from_group_title"],
Expand All @@ -813,7 +813,7 @@ async def removeuser(self, ctx, *users_arg: Union[discord.Member, discord.Role,
await u.send(embed=em)

description = self.bot.formatter.format(
self.bot.config["public_removed_from_group_description"],
self.bot.config["public_removed_from_group_response"],
moderator=ctx.author,
users=", ".join(u.name for u in users),
)
Expand Down Expand Up @@ -1385,12 +1385,14 @@ async def contact(

if not silent and not self.bot.config.get("thread_contact_silently"):
if creator.id == user.id:
description = "You have opened a Modmail thread."
description = self.bot.config["thread_creation_self_contact_response"]
else:
description = f"{creator.name} has opened a Modmail thread."
description = self.bot.formatter.format(
self.bot.config["thread_creation_contact_response"], creator=creator
)

em = discord.Embed(
title="New Thread",
title=self.bot.config["thread_creation_contact_title"],
description=description,
color=self.bot.main_color,
)
Expand Down
15 changes: 11 additions & 4 deletions core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,20 @@ class ConfigManager:
"close_emoji": "\N{LOCK}",
"use_user_id_channel_name": False,
"recipient_thread_close": False,
"thread_show_roles": True,
"thread_show_account_age": True,
"thread_show_join_age": True,
"thread_cancelled": "Cancelled",
"thread_auto_close_silently": False,
"thread_auto_close": isodate.Duration(),
"thread_auto_close_response": "This thread has been closed automatically due to inactivity after {timeout}.",
"thread_creation_response": "The staff team will get back to you as soon as possible.",
"thread_creation_footer": "Your message has been sent",
"thread_contact_silently": False,
"thread_self_closable_creation_footer": "Click the lock to close the thread",
"thread_creation_contact_title": "New Thread",
"thread_creation_self_contact_response": "You have opened a Modmail thread.",
"thread_creation_contact_response": "{creator.name} has opened a Modmail thread.",
"thread_creation_title": "Thread Created",
"thread_close_footer": "Replying will create a new thread",
"thread_close_title": "Thread Closed",
Expand All @@ -85,16 +92,16 @@ class ConfigManager:
"anonymous_snippets": False,
# group conversations
"private_added_to_group_title": "New Thread (Group)",
"private_added_to_group_description": "{moderator.name} has added you to a Modmail thread.",
"private_added_to_group_response": "{moderator.name} has added you to a Modmail thread.",
"private_added_to_group_description_anon": "A moderator has added you to a Modmail thread.",
"public_added_to_group_title": "New User",
"public_added_to_group_description": "{moderator.name} has added {users} to the Modmail thread.",
"public_added_to_group_response": "{moderator.name} has added {users} to the Modmail thread.",
"public_added_to_group_description_anon": "A moderator has added {users} to the Modmail thread.",
"private_removed_from_group_title": "Removed From Thread (Group)",
"private_removed_from_group_description": "{moderator.name} has removed you from the Modmail thread.",
"private_removed_from_group_response": "{moderator.name} has removed you from the Modmail thread.",
"private_removed_from_group_description_anon": "A moderator has removed you from the Modmail thread.",
"public_removed_from_group_title": "User Removed",
"public_removed_from_group_description": "{moderator.name} has removed {users} from the Modmail thread.",
"public_removed_from_group_response": "{moderator.name} has removed {users} from the Modmail thread.",
"public_removed_from_group_description_anon": "A moderator has removed {users} from the Modmail thread.",
# moderation
"recipient_color": str(discord.Color.gold()),
Expand Down
79 changes: 75 additions & 4 deletions core/config_help.json
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,36 @@
"See also: `close_emoji`."
]
},
"thread_show_roles": {
"default": "Yes",
"description": "Shows roles on first message sent in thread channels to mods",
"examples":[
"`{prefix}config set thread_show_roles no`"
],
"notes": [
"See also: `thread_show_account_age`, `thread_show_join_age`."
]
},
"thread_show_account_age": {
"default": "Yes",
"description": "Shows account age on first message sent in thread channels to mods",
"examples":[
"`{prefix}config set thread_show_account_age no`"
],
"notes": [
"See also: `thread_show_roles`, `thread_show_join_age`."
]
},
"thread_show_join_age": {
"default": "Yes",
"description": "Shows join age on first message sent in thread channels to mods",
"examples":[
"`{prefix}config set thread_show_join_age no`"
],
"notes": [
"See also: `thread_show_account_age`, `thread_show_roles`."
]
},
"thread_auto_close_silently": {
"default": "No",
"description": "Setting this configuration will close silently when the thread auto-closes.",
Expand Down Expand Up @@ -302,6 +332,14 @@
"To disable thread cooldown, do `{prefix}config del thread_cooldown`."
]
},
"thread_cancelled": {
"default": "\"Cancelled\"",
"description": "This is the message to display when a thread times out and creation is cancelled.",
"examples": [
"`{prefix}config set thread_cancelled Gone.`"
],
"notes": []
},
"thread_auto_close_response": {
"default": "\"This thread has been closed automatically due to inactivity after {{timeout}}.\"",
"description": "This is the message to display when the thread when the thread auto-closes.",
Expand Down Expand Up @@ -359,6 +397,39 @@
"See also: `thread_creation_title`, `thread_creation_response`, `thread_creation_footer`."
]
},
"thread_creation_contact_title": {
"default": "\"New Thread\"",
"description": "This is the message embed title sent to recipients when contacted.",
"examples": [
"`{prefix}config set thread_creation_contact_title New Message!`"
],
"notes": [
"See also: `thread_creation_self_contact_response`, `thread_creation_contact_response`."
]
},
"thread_creation_self_contact_response": {
"default": "\"You have opened a Modmail thread.\"",
"description": "This is the message embed description sent to recipients when self-contacted.",
"examples": [
"`{prefix}config set thread_creation_contact_title You contacted yourself.`"
],
"notes": [
"`thread_creation_contact_response` is used when contacted by another user.",
"See also: `thread_creation_contact_title`, `thread_creation_contact_response`."
]
},
"thread_creation_contact_response": {
"default": "\"{creator.name} has opened a Modmail thread.\"",
"description": "This is the message embed description sent to recipients when contacted by a mod.",
"examples": [
"`{prefix}config set thread_creation_contact_response New thread opened.`"
],
"notes": [
"You may use the `{{creator}}` variable for access to the [Member](https://discordpy.readthedocs.io/en/latest/api.html#discord.Member) that created the thread.",
"`thread_creation_self_contact_response` is used when contacted by self.",
"See also: `thread_creation_contact_title`, `thread_creation_self_contact_response`."
]
},
"thread_creation_title": {
"default": "\"Thread Created\"",
"description": "This is the message embed title sent to the recipient upon the creation of a new thread.",
Expand Down Expand Up @@ -722,7 +793,7 @@
"See also: `private_added_to_group_description`, `public_added_to_group_title`"
]
},
"private_added_to_group_description": {
"private_added_to_group_response": {
"default": "\"{{moderator.name}} has added you to a Modmail thread.\"",
"description": "This is the message embed content sent to the recipient that is just added to a thread.",
"examples": [
Expand Down Expand Up @@ -758,7 +829,7 @@
"See also: `private_added_to_group_title`, `private_added_to_group_title`"
]
},
"public_added_to_group_description": {
"public_added_to_group_response": {
"default": "\"{{moderator.name}} has added {{users}} to the Modmail thread.\"",
"description": "This is the message embed content sent to all other recipients when someone is added to the thread.",
"examples": [
Expand Down Expand Up @@ -794,7 +865,7 @@
"See also: `private_removed_from_group_description`, `public_removed_from_group_title`"
]
},
"private_removed_from_group_description": {
"private_removed_from_group_response": {
"default": "\"{{moderator.name}} has removed you from the Modmail thread.\"",
"description": "This is the message embed content sent to the recipient that is just removed from a thread.",
"examples": [
Expand Down Expand Up @@ -830,7 +901,7 @@
"See also: `private_removed_from_group_title`, `private_removed_from_group_title`"
]
},
"public_removed_from_group_description": {
"public_removed_from_group_response": {
"default": "\"{{moderator.name}} has removed {{users}} from the Modmail thread.\"",
"description": "This is the message embed content sent to all other recipients when someone is removed from the thread.",
"examples": [
Expand Down
31 changes: 19 additions & 12 deletions core/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ def _format_info_embed(self, user, log_url, log_count, color):
# key = log_url.split('/')[-1]

role_names = ""
if member is not None:
if member is not None and self.bot.config["thread_show_roles"]:
sep_server = self.bot.using_multiple_server_setup
separator = ", " if sep_server else " "

Expand All @@ -309,13 +309,11 @@ def _format_info_embed(self, user, log_url, log_count, color):
role_names = separator.join(roles)

created = str((time - user.created_at).days)
embed = discord.Embed(
color=color, description=f"{user.mention} was created {days(created)}", timestamp=time
)
user_info = []
if self.bot.config["thread_show_account_age"]:
user_info.append(f"was created {days(created)}")

# if not role_names:
# embed.add_field(name='Mention', value=user.mention)
# embed.add_field(name='Registered', value=created + days(created))
embed = discord.Embed(color=color, description=user.mention, timestamp=time)

if user.dm_channel:
footer = f"User ID: {user.id} • DM ID: {user.dm_channel.id}"
Expand All @@ -328,7 +326,8 @@ def _format_info_embed(self, user, log_url, log_count, color):
if member is not None:
joined = str((time - member.joined_at).days)
# embed.add_field(name='Joined', value=joined + days(joined))
embed.description += f", joined {days(joined)}"
if self.bot.config["thread_show_join_age"]:
user_info.append(f"joined {days(joined)}")

if member.nick:
embed.add_field(name="Nickname", value=member.nick, inline=True)
Expand All @@ -338,10 +337,12 @@ def _format_info_embed(self, user, log_url, log_count, color):
else:
embed.set_footer(text=f"{footer} • (not in main server)")

embed.description += ", ".join(user_info)

if log_count is not None:
# embed.add_field(name="Past logs", value=f"{log_count}")
connector = "with" if user_info else "has"
thread = "thread" if log_count == 1 else "threads"
embed.description += f" with **{log_count or 'no'}** past {thread}."
embed.description += f" {connector} **{log_count or 'no'}** past {thread}."
else:
embed.description += "."

Expand Down Expand Up @@ -1336,15 +1337,21 @@ async def create(
self.bot.loop.create_task(
destination.send(
embed=discord.Embed(
title="Cancelled", description="Timed out", color=self.bot.error_color
title=self.bot.config["thread_cancelled"],
description="Timed out",
color=self.bot.error_color,
)
)
)
else:
if str(r.emoji) == deny_emoji:
thread.cancelled = True
self.bot.loop.create_task(
destination.send(embed=discord.Embed(title="Cancelled", color=self.bot.error_color))
destination.send(
embed=discord.Embed(
title=self.bot.config["thread_cancelled"], color=self.bot.error_color
)
)
)

async def remove_reactions():
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ extend-exclude = '''

[tool.poetry]
name = 'Modmail'
version = '3.10.0-dev5'
version = '3.10.0-dev6'
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."
license = 'AGPL-3.0-only'
authors = [
Expand Down

0 comments on commit daf04b0

Please sign in to comment.