diff --git a/README.md b/README.md index df39feb..9a419aa 100644 --- a/README.md +++ b/README.md @@ -30,6 +30,8 @@ Sometimes it’s nice to be able to do things quickly... Here’s where macros c - `?fraud` - redirect to Fraud Squad - `?thread` - remove the reaction and all Nephthys replies to unclutter duplicates - `?shipwrights` - redirect to #ask-the-shipwrights +- `?lqvote` - explain how to cast high quality votes + - more to come?? feel free to PR your own into hackclub/nephthys or tell me what you want ### Stale diff --git a/nephthys/macros/__init__.py b/nephthys/macros/__init__.py index 9a36ce7..654b001 100644 --- a/nephthys/macros/__init__.py +++ b/nephthys/macros/__init__.py @@ -4,6 +4,7 @@ from nephthys.macros.fraud import Fraud from nephthys.macros.hello_world import HelloWorld from nephthys.macros.identity import Identity +from nephthys.macros.low_quality_votes import LowQualityVotes from nephthys.macros.reopen import Reopen from nephthys.macros.resolve import Resolve from nephthys.macros.shipcertqueue import ShipCertQueue @@ -32,6 +33,7 @@ FulfillmentReminder, Shipwrights, TeamTag, + LowQualityVotes, ] macros = [macro() for macro in macro_list] diff --git a/nephthys/macros/low_quality_votes.py b/nephthys/macros/low_quality_votes.py new file mode 100644 index 0000000..d84ce16 --- /dev/null +++ b/nephthys/macros/low_quality_votes.py @@ -0,0 +1,39 @@ +from nephthys.actions.resolve import resolve +from nephthys.macros.types import Macro +from nephthys.utils.env import env +from nephthys.utils.slack_user import get_user_profile +from nephthys.utils.ticket_methods import reply_to_ticket + + +class LowQualityVotes(Macro): + name = "lqvote" + aliases = ["lqvote", "lqvotes"] + + async def run(self, ticket, helper, **kwargs): + """ + Macro to warn users their votes are being marked low-quality. + """ + macro_text = env.transcript.low_quality_votes_macro + if not macro_text: + await env.slack_client.chat_postEphemeral( + channel=env.slack_help_channel, + thread_ts=ticket.msgTs, + user=helper.slackId, + text=f"Invalid macro: The `{self.name}` macro is not configured for this channel.", + ) + return + sender = await env.db.user.find_first(where={"id": ticket.openedById}) + if not sender: + return + user = await get_user_profile(sender.slackId) + await reply_to_ticket( + text=macro_text.replace("(user)", user.display_name()), + ticket=ticket, + client=env.slack_client, + ) + await resolve( + ts=ticket.msgTs, + resolver=helper.slackId, + client=env.slack_client, + send_resolved_message=False, + ) diff --git a/nephthys/transcripts/transcript.py b/nephthys/transcripts/transcript.py index ee8f0cf..7c18010 100644 --- a/nephthys/transcripts/transcript.py +++ b/nephthys/transcripts/transcript.py @@ -100,6 +100,11 @@ def program_snake_case(self) -> str: description="Message to be sent when the ship cert queue macro is used (only applies to Flavortown and SoM)", ) + low_quality_votes_macro: str | None = Field( + default=None, + description="Message to be sent when votes are marked low-quality (Flavortown)", + ) + not_allowed_channel: str = Field( default="", description="Message for unauthorized channel access" ) diff --git a/nephthys/transcripts/transcripts/flavortown.py b/nephthys/transcripts/transcripts/flavortown.py index 29cfc5e..7c82ee0 100644 --- a/nephthys/transcripts/transcripts/flavortown.py +++ b/nephthys/transcripts/transcripts/flavortown.py @@ -54,3 +54,13 @@ class Flavortown(Transcript): ship_cert_queue_macro: str | None = ( "Hey (user), we currently have a backlog of projects waiting to be certified. Please be patient.\n\n*You can keep track of the queue !*" ) + + low_quality_votes_macro: str | None = ( + "Hey (user), some of your votes are likely being marked as low quality and are discarded.\n\n" + "When you're , make sure that you are:\n" + "• Checking both the repo and demo links\n" + "• Spending some time looking through the project's devlogs\n" + "• Giving good, thoughtful scores and feedback\n" + "• Generally caring and not rushing through voting\n\n" + "_Low quality votes won't count towards your vote requirement!_" + )