diff options
author | 2023-04-08 20:02:15 +0100 | |
---|---|---|
committer | 2023-04-08 20:02:15 +0100 | |
commit | 5e6e21dbe63d5f9da5a787d8987a02a454f21103 (patch) | |
tree | e91e117522f7fd64faa8b1bed706074a258382c9 | |
parent | Merge pull request #2518 from python-discord/dependabot/pip/coverage-7.2.3 (diff) | |
parent | Merge branch 'main' into swfarnsworth/ping-on-thread-close (diff) |
Merge pull request #2504 from python-discord/swfarnsworth/ping-on-thread-close
Ping help thread owner if thread closes without engagement.
-rw-r--r-- | bot/exts/help_channels/_channel.py | 21 |
1 files changed, 16 insertions, 5 deletions
diff --git a/bot/exts/help_channels/_channel.py b/bot/exts/help_channels/_channel.py index 670a10446..b1a319145 100644 --- a/bot/exts/help_channels/_channel.py +++ b/bot/exts/help_channels/_channel.py @@ -17,13 +17,13 @@ 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 = f""" +NEW_POST_MSG = """ **Remember to:** • **Ask** your Python question, not if you can ask or if there's an expert who can help. • **Show** a code sample as text (rather than a screenshot) and the error message, if you've got one. • **Explain** what you expect to happen and what actually happens. -For more tips, check out our guide on [asking good questions]({ASKING_GUIDE_URL}). +:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs. """ NEW_POST_FOOTER = f"Closes after a period of inactivity, or when you send {constants.Bot.prefix}close." NEW_POST_ICON_URL = f"{BRANDING_REPO_RAW_URL}/main/icons/checkmark/green-checkmark-dist.png" @@ -46,8 +46,19 @@ async def _close_help_post(closed_post: discord.Thread, closing_reason: _stats.C """Close the help post and record stats.""" embed = discord.Embed(description=CLOSED_POST_MSG) embed.set_author(name=f"{POST_TITLE} closed", icon_url=CLOSED_POST_ICON_URL) - - await closed_post.send(embed=embed) + message = '' + + # Include a ping in the close message if no one else engages, to encourage them + # to read the guide for asking better questions + if closing_reason == _stats.ClosingReason.INACTIVE and closed_post.owner is not None: + participant_ids = { + message.author.id async for message in closed_post.history(limit=100, oldest_first=False) + if not message.author.bot + } + if participant_ids == {closed_post.owner_id}: + message = closed_post.owner.mention + + await closed_post.send(message, embed=embed) await closed_post.edit(archived=True, locked=True, reason="Locked a closed help post") _stats.report_post_count() @@ -75,7 +86,7 @@ async def send_opened_post_message(post: discord.Thread) -> None: ) embed.set_author(name=f"{POST_TITLE} opened", icon_url=NEW_POST_ICON_URL) embed.set_footer(text=NEW_POST_FOOTER) - await post.send(embed=embed) + await post.send(embed=embed, content=post.owner.mention) async def send_opened_post_dm(post: discord.Thread) -> None: |