-
Notifications
You must be signed in to change notification settings - Fork 10
Attempt to auto jail mention bombers. #351
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
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,8 +46,8 @@ def setup(self): | |
| pass | ||
|
|
||
| @staticmethod | ||
| def build_reason(ctx, action, minutes, reason, past=False): | ||
| full_reason = StringBuilder(f"{action} by {user_discrim(ctx.author)}") | ||
| def build_reason(message, action, minutes, reason, past=False): | ||
| full_reason = StringBuilder(f"{action} by {user_discrim(message.author)}") | ||
| if minutes: | ||
| full_reason.write( | ||
| f" {'for' if past else 'in'} {minutes} minute{plural(minutes)}" | ||
|
|
@@ -56,7 +56,7 @@ def build_reason(ctx, action, minutes, reason, past=False): | |
| full_reason.write(f" with reason: {reason}") | ||
| return str(full_reason) | ||
|
|
||
| async def remove_roles(self, ctx, member, minutes, action, reason): | ||
| async def remove_roles(self, message, member, minutes, action, reason): | ||
AraHaan marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| assert minutes | ||
|
|
||
| logger.info( | ||
|
|
@@ -71,7 +71,7 @@ async def remove_roles(self, ctx, member, minutes, action, reason): | |
| task = PunishTask( | ||
| self.bot, | ||
| None, | ||
| ctx.author, | ||
| message.author, | ||
| timestamp, | ||
| None, | ||
| member=member, | ||
|
|
@@ -169,24 +169,27 @@ async def unmute( | |
| else: | ||
| await self.bot.punish.unjail(ctx.guild, member, reason) | ||
|
|
||
| async def perform_jail(self, ctx, member, minutes, reason): | ||
| roles = self.bot.sql.settings.get_special_roles(ctx.guild) | ||
| async def perform_jail_internal(self, message, member, minutes, reason): | ||
| roles = self.bot.sql.settings.get_special_roles(message.guild) | ||
| if roles.jail is None: | ||
| raise CommandFailed(content="No configured jail role") | ||
|
|
||
| if member.top_role >= ctx.me.top_role: | ||
| if member.top_role >= self.bot.user.top_role: | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there a way to get the |
||
| raise ManualCheckFailure("I don't have permission to jail this user") | ||
|
|
||
| minutes = max(minutes, 0) | ||
| reason = self.build_reason(ctx, "Jailed", minutes, reason) | ||
| reason = self.build_reason(message, "Jailed", minutes, reason) | ||
|
|
||
| await self.bot.punish.jail(ctx.guild, member, reason) | ||
| await self.bot.punish.jail(message.guild, member, reason) | ||
|
|
||
| # If a delayed event, schedule a Navi task | ||
| if minutes: | ||
| await self.remove_roles( | ||
| ctx, member, minutes, PunishAction.RELIEVE_JAIL, reason | ||
| message, member, minutes, PunishAction.RELIEVE_JAIL, reason | ||
| ) | ||
|
|
||
| async def perform_jail(self, ctx, member, minutes, reason): | ||
| await self.perform_jail_internal(self, ctx.message, member, minutes, reason) | ||
|
|
||
| @commands.command(name="jail", aliases=["dunce"]) | ||
| @commands.guild_only() | ||
|
|
@@ -201,6 +204,15 @@ async def jail(self, ctx, member: MemberConv, *, reason: str = None): | |
|
|
||
| await self.perform_jail(ctx, member, 0, reason) | ||
|
|
||
| async def on_message(self, message): | ||
| """ | ||
| Bot Event. | ||
| :param message: Messages. | ||
| :return: Nothing. | ||
| """ | ||
| if len(message.mentions) > 5: | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. On another thought I probably should ensure that this line does not count the same mention more than once like for example if they did But then again it could be considered annoying too so probably should dunce them too in that case as well. Edit: Or even the case where they mention themselves multiple times too.
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is too simplistic. In addition to the self-mentioning problem above, this also doesn't account for multiple messages in quick succession with multiple mentions. Finally, if we have a threshold like this it should be configurable per-guild.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Alright I might need to look further into what you do to store the configuration, also might need to somehow store a datetime of the user's last mention like this as well so that way it can pick up any and all history on that action they done? |
||
| await self.perform_jail_internal(message, message.author, 0, "Mention Bombing.") | ||
|
||
|
|
||
| @commands.command(name="djail", aliases=["ddunce", "timejail", "timedunce"]) | ||
| @commands.guild_only() | ||
| @permissions.check_perm("manage_roles") | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.