ziyadm / test-bot-repo

0 stars 0 forks source link

give the player our expected solution if they run out of time #133

Closed github-actions[bot] closed 1 year ago

github-actions[bot] commented 1 year ago

https://github.com/ziyadm/test-bot-repo/blob/15ed3fd46896b0528809dea76687118683ea9b99/messenger.py#L57


class Messenger:
    def __init__(
        self,
        *,
        discord_client: DiscordClient,
    ):
        self.__discord_client = discord_client

    @staticmethod
    def review_thread_name(*, for_mission: Mission, for_stage: Stage):
        return "-".join(
            [
                str(for_stage),
                for_mission.fields.discord_channel_id,
                for_mission.fields.question_id,
            ]
        )

    async def player_is_out_of_questions(self, *, player: User):
        player_discord_member = await self.__discord_client.member(
            member_id=player.fields.discord_id
        )
        path_channel = await self.__discord_client.channel(
            channel_id=player.fields.discord_channel_id
        )
        guild_owner = await self.__discord_client.guild_owner()
        _ = await self.__discord_client.with_typing_time_determined_by_number_of_words(
            message=f"""Congrats {player_discord_member.mention}!! You've done every training mission we have to offer!""",
            channel=path_channel,
        )
        _ = await self.__discord_client.with_typing_time_determined_by_number_of_words(
            message=f"""Your time to meet {guild_owner.mention} has finally come...""",
            channel=path_channel,
        )

    async def player_is_out_of_time_for_mission(self, *, mission_past_due: Mission):
        mission_channel = await self.__discord_client.channel(
            channel_id=mission_past_due.fields.discord_channel_id
        )
        _ = await self.__discord_client.with_typing_time_determined_by_number_of_words(
            "*Beep beep beep!*", mission_channel
        )
        # TODO: give the player our expected solution if they run out of time
        _ = await self.__discord_client.with_typing_time_determined_by_number_of_words(
            "**Times up!**", mission_channel
        )

    async def review_needs_to_be_claimed(self, for_mission: Mission):
        all_reviews_channel = await self.__discord_client.all_reviews_channel()
        unclaimed_review_thread = list(
            filter(
                lambda thread: thread.name
                == self.review_thread_name(
                    for_mission=for_mission,
                    for_stage=for_mission.fields.stage.previous(),
                ),
                all_reviews_channel.threads,
            )
        )[0]
        _ = await unclaimed_review_thread.send("@everyone ping! race to claim this!!")

    async def reviewer_needs_to_review(self, for_mission: Mission):
        review_channel = await self.__discord_client.channel(
            channel_id=for_mission.fields.review_discord_channel_id
        )
        reviewer_discord_member = await self.__discord_client.member(
            member_id=for_mission.fields.reviewer_discord_id
        )
        _ = await review_channel.send(
            f"""{reviewer_discord_member.mention} dont leave them hanging, review this!!"""
        )

    async def command_cannot_be_run_here(
        self,
        where_to_follow_up: discord.Webhook,
github-actions[bot] commented 1 year ago

Closed in 9c90714bb889c0aa006a74acdd5933265d6838c1