From 3beee54aaf77e0ef5dd18852955c8914badf060c Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 17:15:36 +0000 Subject: [PATCH 1/7] Remove unneeded constant --- bot/exts/help_channels/_channel.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 9d76adf656..06d174e5cc 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -15,7 +15,6 @@ ASKING_GUIDE_URL = "https://pythondiscord.com/pages/asking-good-questions/" BRANDING_REPO_RAW_URL = "https://raw.githubusercontent.com/python-discord/branding" -POST_TITLE = "Python help channel" NEW_POST_MSG = """ **Remember to:** @@ -83,7 +82,7 @@ async def send_opened_post_message(post: discord.Thread) -> None: color=constants.Colours.bright_green, description=NEW_POST_MSG, ) - embed.set_author(name=f"{POST_TITLE} opened", icon_url=NEW_POST_ICON_URL) + embed.set_author(name="Python help channel opened", icon_url=NEW_POST_ICON_URL) embed.set_footer(text=NEW_POST_FOOTER) await post.send(embed=embed, content=post.owner.mention) From ea41edc4c42312013a77c8cc7348ab91bf1c3a23 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 17:15:59 +0000 Subject: [PATCH 2/7] Significantly shorten help channel close message --- bot/exts/help_channels/_channel.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 06d174e5cc..de679447d4 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -28,8 +28,8 @@ NEW_POST_ICON_URL = f"{BRANDING_REPO_RAW_URL}/main/icons/checkmark/green-checkmark-dist.png" CLOSED_POST_MSG = f""" -This help channel has been closed and it's no longer possible to send messages here. \ -If your question wasn't answered, feel free to create a new post in <#{constants.Channels.python_help}>. \ +This help channel has been closed. \ +Feel free to create a new post in <#{constants.Channels.python_help}>. \ To maximize your chances of getting a response, check out this guide on [asking good questions]({ASKING_GUIDE_URL}). """ CLOSED_POST_ICON_URL = f"{BRANDING_REPO_RAW_URL}/main/icons/zzz/zzz-dist.png" From 9ae49228be556faec0fe5dd135262004f8125139 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 17:16:13 +0000 Subject: [PATCH 3/7] Change closing embed title based on close reason --- bot/exts/help_channels/_channel.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index de679447d4..36665e1855 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -47,7 +47,16 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C closed_post = await get_or_fetch_channel(bot.instance, closed_post.id) embed = discord.Embed(description=CLOSED_POST_MSG) - embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL) + if closing_reason == _stats.ClosingReason.CLEANUP: + close_title = "Python help channel closed as OP left server" + elif closing_reason == _stats.ClosingReason.COMMAND: + close_title = f"Python help channel closed by OP with {constants.Bot.prefix}close" + elif closing_reason == _stats.ClosingReason.INACTIVE: + close_title = "Python help channel closed for inactivity" + else: + close_title = "Python help channel closed" + + embed.set_author(name=close_title, icon_url=CLOSED_POST_ICON_URL) message = "" # Include a ping in the close message if no one else engages, to encourage them From 6ee0b8af8a18a2d23c8bbee897a00a7f0fadde6e Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 17:20:26 +0000 Subject: [PATCH 4/7] Add closing reason for when OP closes uses native Discord close option --- bot/exts/help_channels/_channel.py | 4 +++- bot/exts/help_channels/_stats.py | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 36665e1855..1d43b6177a 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -53,6 +53,8 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C close_title = f"Python help channel closed by OP with {constants.Bot.prefix}close" elif closing_reason == _stats.ClosingReason.INACTIVE: close_title = "Python help channel closed for inactivity" + elif closing_reason == _stats.ClosingReason.NATIVE: + close_title = "Python help channel closed by OP" else: close_title = "Python help channel closed" @@ -138,7 +140,7 @@ async def help_post_archived(archived_post: discord.Thread) -> None: if thread_update.user.id == bot.instance.user.id: return - await _close_help_post(archived_post, _stats.ClosingReason.INACTIVE) + await _close_help_post(archived_post, _stats.ClosingReason.NATIVE) async def help_post_deleted(deleted_post_event: discord.RawThreadDeleteEvent) -> None: diff --git a/bot/exts/help_channels/_stats.py b/bot/exts/help_channels/_stats.py index 6ca40139b3..687ebc80cd 100644 --- a/bot/exts/help_channels/_stats.py +++ b/bot/exts/help_channels/_stats.py @@ -16,6 +16,7 @@ class ClosingReason(Enum): COMMAND = "command" INACTIVE = "auto.inactive" + NATIVE = "auto.native" DELETED = "auto.deleted" CLEANUP = "auto.cleanup" From 3fbd94acd81eda706f82d9682bd3ddeef932d7f6 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 17:22:29 +0000 Subject: [PATCH 5/7] Don't repeat start of close message in every if branch --- bot/exts/help_channels/_channel.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 1d43b6177a..1b847bdb86 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -47,16 +47,16 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C closed_post = await get_or_fetch_channel(bot.instance, closed_post.id) embed = discord.Embed(description=CLOSED_POST_MSG) + close_title = "Python help channel closed" if closing_reason == _stats.ClosingReason.CLEANUP: - close_title = "Python help channel closed as OP left server" + close_title += " as OP left server" elif closing_reason == _stats.ClosingReason.COMMAND: - close_title = f"Python help channel closed by OP with {constants.Bot.prefix}close" + close_title += f" by OP with {constants.Bot.prefix}close" elif closing_reason == _stats.ClosingReason.INACTIVE: - close_title = "Python help channel closed for inactivity" + close_title += " for inactivity" elif closing_reason == _stats.ClosingReason.NATIVE: - close_title = "Python help channel closed by OP" - else: - close_title = "Python help channel closed" + close_title += " by OP" + embed.set_author(name=close_title, icon_url=CLOSED_POST_ICON_URL) message = "" From e1945dcfe17cf621f97620843845a30bfe06c813 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 18:09:50 +0000 Subject: [PATCH 6/7] More specific close message for native close --- bot/exts/help_channels/_channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 1b847bdb86..d0f6e1b761 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -55,7 +55,7 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C elif closing_reason == _stats.ClosingReason.INACTIVE: close_title += " for inactivity" elif closing_reason == _stats.ClosingReason.NATIVE: - close_title += " by OP" + close_title += " using Discord native close action" embed.set_author(name=close_title, icon_url=CLOSED_POST_ICON_URL) From b237eef91cb48c8be2df5c215ac67f75e5c5b394 Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 18 Jan 2025 18:10:06 +0000 Subject: [PATCH 7/7] !close can also be used by moderators, not just OP --- bot/exts/help_channels/_channel.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index d0f6e1b761..1de6e5a83f 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -51,7 +51,7 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C if closing_reason == _stats.ClosingReason.CLEANUP: close_title += " as OP left server" elif closing_reason == _stats.ClosingReason.COMMAND: - close_title += f" by OP with {constants.Bot.prefix}close" + close_title += f" with {constants.Bot.prefix}close" elif closing_reason == _stats.ClosingReason.INACTIVE: close_title += " for inactivity" elif closing_reason == _stats.ClosingReason.NATIVE: