コード例 #1
0
    async def prevote(self, ctx: Context, vote: str):
        """Prevote in an ongoing nomination.

        vote: The prevote to queue.

        When it's your turn to vote, this will automatically submit the queued vote.
        """
        actual_vt = int(to_bool(vote, "vote"))
        await ctx.bot.game.current_day.current_vote.prevote(
            ctx, get_player(ctx.bot.game, ctx.author.id), actual_vt)
コード例 #2
0
    async def emergencyvote(
        self,
        ctx: Context,
        vote: str,
        time: int,
        specific: str = "yes",
    ):
        """Change your emergency vote.

        vote: The vote you want to set, yes or no.
        time: The time in minutes for the vote to trigger.
        specific: Whether this emergency is bot-specific, yes or no. Defaults to yes.
        """
        vote_actual = to_bool(vote, "vote")
        specific_actual = to_bool(specific, "argument")
        preferences = load_preferences(ctx.message.author)
        if specific_actual:
            preferences.specific_emergencys[ctx.bot.user.id] = (vote_actual,
                                                                time)
            preferences.save_preferences()
            await safe_send(
                ctx,
                ("Successfully set a emergency vote of {vote} "
                 "in {time} minutes for {botName}.").format(
                     vote=("no", "yes")[vote_actual],
                     time=str(time),
                     botName=ctx.bot.server.get_member(
                         ctx.bot.user.id).display_name,
                 ),
            )
        else:
            preferences.emergency_vote = (vote_actual, time)
            preferences.save_preferences()
            await safe_send(
                ctx,
                ("Successfully set a generic emergency vote of "
                 "{vote} in {time} minutes.").format(vote=("no",
                                                           "yes")[vote_actual],
                                                     time=str(time)),
            )
コード例 #3
0
    async def proxyvote(self, ctx: "VoteContext", voter: str, vote: str):
        """Simulate a vote by a player.

        voter: The player to vote for.
        vote: The vote to input.
        """
        voter_actual = await to_player(ctx, voter)
        vote_actual = to_bool(vote, "vote")
        if ctx.bot.game.current_day.current_vote.to_vote != voter_actual:
            await safe_send(
                ctx,
                "It is not {player}'s vote. It is {actual_voter}'s vote.".format(
                    actual_voter=ctx.bot.game.current_day.current_vote.to_vote.nick,
                    player=voter_actual.nick,
                ),
            )
            return
        await ctx.bot.game.current_day.current_vote.vote(ctx, voter_actual, vote_actual)
        await safe_send(ctx, f"Successfully voted for {voter_actual.nick}.")
コード例 #4
0
    async def removeemergencyvote(self, ctx: Context, specific: str = "yes"):
        """Remove your emergency vote.

        specific: Whether to remove the bot-specific emergency vote or the generic one.
        """
        specific_actual = to_bool(specific, "argument")
        preferences = load_preferences(ctx.message.author)
        if specific_actual:
            try:
                del preferences.specific_emergencys[ctx.bot.user.id]
                preferences.save_preferences()
                await safe_send(
                    ctx,
                    (
                        "Successfully removed your bot-specific emergency vote. "
                        "Please note any generic emergency vote will now apply."
                    ),
                )
            except KeyError:
                await safe_send(
                    ctx,
                    "You do not have a specific emergency vote with {botName}.".format(
                        botName=ctx.bot.server.get_member(ctx.bot.user.id).display_name
                    ),
                )
        else:
            if preferences.emergency_vote[1] is not None:
                preferences.emergency_vote = (0, None)
                preferences.save_preferences()
                await safe_send(
                    ctx,
                    (
                        "Successfully removed your generic emergency vote. "
                        "Please note any bot-specific emergency votes will still apply."
                    ),
                )
            else:
                await safe_send(ctx, "You do not have a generic emergency vote.")
コード例 #5
0
    async def vote(self, ctx: Context, *, vote: str):
        """Vote in an ongoing nomination.

        vote: The vote to submit.
        """
        vote_actual = to_bool(vote, "vote")

        player = get_player(ctx.bot.game, ctx.message.author.id)

        # verify it's their turn to vote
        if ctx.bot.game.current_day.current_vote.to_vote != player:
            await safe_send(
                ctx,
                ("It is {actual_voter}'s vote, not yours, silly! "
                 "(Unless this is a bug. In which case I'm silly. "
                 "I hope I'm not silly.)").format(
                     actual_voter=ctx.bot.game.current_day.current_vote.
                     to_vote.nick),
            )

        # do the vote
        await ctx.bot.game.current_day.current_vote.vote(
            ctx, player, vote_actual)
コード例 #6
0
    async def setpronouns(
        self,
        ctx: Context,
        subjective: str,
        objective: str,
        adjective: str,
        posessive: str,
        reflexive: str,
        plural: str = "no",
    ):
        """Set your pronouns for bot messages.

        subjective: The subjective pronoun, for instance 'they' or 'she'.
        objective: The objective pronoun, for instance 'them' or 'her'.
        adjective: The posessive adjective, for instance 'their' or 'her'.
        posessive: The posessive pronoun, for instance 'theirs' or 'hers'.
        reflexive: The reflexive pronoun, for instance 'themselves' or 'herself'.
        plural: Whether the bot should use plural grammar with your pronouns.
            For instance, 'they are about to die' or 'she is about to die'.

        You can also fill in the blank:
            [subjective] is/are the Imp.
            The Imp is [objective].  # TODO: this is apparently bad grammar
            It is [adjective] character.
            The character is [posessive].
            [subjective] made the Minion a Demon by targeting [reflexive].

        For example:
            They are the Imp.
            The Imp is them.
            It is their character.
            The character is theirs.
            They made the Minion a Demon by targetting themselves.

        These inputs are case-insensitive.

        If you use this to mock trans people, I will blacklist you from using the bot. <3
        """
        plural_actual = to_bool(plural, "argument")

        preferences = load_preferences(ctx.message.author)
        preferences.pronouns = (
            subjective,
            objective,
            adjective,
            posessive,
            reflexive,
            plural_actual,
        )
        preferences.save_preferences()
        await safe_send(
            ctx,
            ("Successfully set your pronouns! "
             "You are valid and thank you for trusting me with them!\n"
             "Here's a quick example so you can make sure you got the grammar right:"
             "\n{subjective} {verb} the Imp."
             "\nThe Imp is {objective}."
             "\nIt is {adjective} character."
             "\nThe character is {posessive}."
             "\n{subjective} made the Minion a Demon by targeting {reflexive}."
             ).format(
                 reflexive=reflexive,
                 subjective=subjective.capitalize(),
                 verb=["is", "are"][plural_actual],
                 objective=objective,
                 adjective=adjective,
                 posessive=posessive,
             ),
        )