Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add `reason` to infraction message when the actor is the bot itself #476

Closed
SebastiaanZ opened this issue Oct 1, 2019 · 0 comments · Fixed by #504

Comments

@SebastiaanZ
Copy link
Member

commented Oct 1, 2019

We recently removed the reason from the infraction confirmation message. The reason was that if the infraction was manually invoked, both the message that contained the command and the confirmation message would contain the reason, which would take up a lot of vertical space when the reason had some length.

However, when an infraction was invoked automatically (e.g., by the AntiSpam cog), having the reason in the infraction notification actually provided context to what's going on. That context is now missing. (See the examples at the bottom of this issue.)

Proposal

  • Add the reason field back to the infraction confirmation message when the actor of the infraction is the bot itself.

Edit: @MarkKoz is currently doing major work on the moderation cog. To prevent major merge conflicts, I've added the stalled status for now.

Note: Currently, the way the AntiSpam cog gets Context for the infraction causes the actor to be set to the offender, not the bot:

bot/bot/cogs/antispam.py

Lines 205 to 212 in 71a3ac9

async def punish(self, msg: Message, member: Member, reason: str) -> None:
"""Punishes the given member for triggering an antispam rule."""
if not any(role.id == self.muted_role.id for role in member.roles):
remove_role_after = AntiSpamConfig.punishment['remove_after']
# We need context, let's get it
context = await self.bot.get_context(msg)

One way to get around that is to patch the context object by setting the author attribute to the bot itself. This is a fix that should probably happen regardless of the reason field, but it makes sense to include it here.

Examples of before and after

Before the removal of reason

mute_reaction

After the removal of reason

mute_no_reason

@sco1 sco1 added this to To Do in Bot Tracking Oct 1, 2019
@SebastiaanZ SebastiaanZ self-assigned this Oct 8, 2019
SebastiaanZ added a commit that referenced this issue Oct 8, 2019
As mentioned in #476, the bot currently sets the actor of infractions
applied due to an antispam rule trigger to the offending member. The
reason is that we get a `Context` object from the message that
triggered the antispam rule, which was sent by the offender.

I've changed it by patching both available author attributes,
`Context.author` and `Context.message.author` with the bot user.
SebastiaanZ added a commit that referenced this issue Oct 8, 2019
#476

We recently decided to hide the reason in the confirmation message
the bot sends after applying an infraction. In most situations, this
makes sense, since the message containing the invocation command
already contains the reason.

However, if the infraction was triggered by the bot itself (e.g., an
antispam trigger), this means that we're missing information that
provides context to the infraction.

This commit adds the reason back to the confirmation message, but
only if the actor of the infraction was the bot itself.

Closes #476
@MarkKoz MarkKoz closed this in #504 Oct 8, 2019
Bot Tracking automation moved this from To Do to Done Oct 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Bot Tracking
  
Done
1 participant
You can’t perform that action at this time.