Пример #1
0
 async def escalate_user(user):
     history = escalation_history.UserEscalationHistory(
         self.bot, user, ctx.guild)
     try:
         result = await history.escalate(ctx.author, reason)
         response = (f"Action: {result.current_rung.display_name}. "
                     f"Next Time: {result.next_rung.display_name}. ")
         expiration = 'Expiration: Never'
         if result.expiration is not None:
             expiration = f'Expiration: {str(result.expiration)}'
         return response + expiration
     except escalation_history.EscalationException as e:
         return 'Error: ' + e.message
Пример #2
0
 async def __apply_pending_deescalation(self, session, deesc):
     guild = self.bot.get_guild(deesc.guild_id)
     if guild is not None:
         history = escalation_history.UserEscalationHistory(
             bot=self.bot,
             user=fake.FakeSnowflake(deesc.user_id),
             guild=guild,
             session=session)
         await history.apply_diff(guild.me,
                                  'Automatic Deescalation',
                                  deesc.amount,
                                  execute=False)
     session.delete(deesc)
     session.commit()
Пример #3
0
 async def _apply_escalate(self, action: proto.Action) -> None:
     assert action.WhichOneof('details') == 'escalate'
     guild = self.__get_guild(action)
     if guild is None:
         return
     history = escalation_history.UserEscalationHistory(
         self.bot, fake.FakeSnowflake(id=action.user_id), guild)
     # TODO(james7132): Log this
     if action.escalate.amount == 0:
         return
     await history.apply_diff(guild.me,
                              action.reason,
                              action.escalate.amount,
                              execute=action.escalate.amount > 0)
Пример #4
0
    async def escalate_history(self, ctx, user: discord.Member):
        """Deesclates a user and applies the appropriate moderation action.

        A history of escalation events can be seen with ~escalate history.
        See: ~help escalate history.

        Requires the escalation ladder to be configured properly.
        For more information:
        https://github.com/james7132/Hourai/wiki/Escalation-Ladder
        """
        history = escalation_history.UserEscalationHistory(
            self.bot, user, ctx.guild)

        comps = [f"**Escalation History for {user.mention}**"]
        comps.append(await self.__build_escalation_history_table(history))
        await ctx.send(format.vertical_list(comps))
Пример #5
0
    async def escalate_history(self, ctx, user: typing.Union[discord.Member,
                                                             int]):
        """Deesclates a user and applies the appropriate moderation action.

        A history of escalation events can be seen with ~escalate history.
        See: ~help escalate history.

        Requires the escalation ladder to be configured properly.
        For more information:
        https://github.com/james7132/Hourai/wiki/Escalation-Ladder
        """
        name = str(user)
        user = fake.FakeSnowflake(user) if isinstance(user, int) else user
        history = escalation_history.UserEscalationHistory(
            self.bot, user, ctx.guild)

        comps = [f"**Escalation History for {name}**"]
        comps.append(await self.__build_escalation_history_table(history))
        await ctx.send(format.vertical_list(comps))