aboutsummaryrefslogtreecommitdiffstats
path: root/bot/cogs/watchchannels/bigbrother.py
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2020-03-06 14:35:17 -0600
committerGravatar Daniel Brown <[email protected]>2020-03-09 10:43:16 -0500
commitf1eb927fb1aa1fffc9f3e03a2987e03361d9f0b9 (patch)
treeac5b78178e6bdce2a712d92c69259cd8906d3aae /bot/cogs/watchchannels/bigbrother.py
parentMerge pull request #822 from python-discord/bug/mod/792/null-attachments (diff)
Added BigBrother Helper Methods
- Added apply_unwatch() and migrated the code from the unwatch command to it. This will give us more control regarding testing and also determining when unwatches trigger. - Added apply_watch() and migrated the code from the watch command to it. Again, this will assist with testing and could make it easier to automate adding to the watch list if need be. - Added unwatch call to apply_ban. User will only be removed from the watch list if they were permanently banned. They will not be removed if it was only temporary. Signed-off-by: Daniel Brown <[email protected]>
Diffstat (limited to '')
-rw-r--r--bot/cogs/watchchannels/bigbrother.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/bot/cogs/watchchannels/bigbrother.py b/bot/cogs/watchchannels/bigbrother.py
index c601e0d4d..75b66839e 100644
--- a/bot/cogs/watchchannels/bigbrother.py
+++ b/bot/cogs/watchchannels/bigbrother.py
@@ -52,6 +52,16 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
A `reason` for adding the user to Big Brother is required and will be displayed
in the header when relaying messages of this user to the watchchannel.
"""
+ await self.apply_watch(ctx, user, reason)
+
+ @bigbrother_group.command(name='unwatch', aliases=('uw',))
+ @with_role(*MODERATION_ROLES)
+ async def unwatch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None:
+ """Stop relaying messages by the given `user`."""
+ await self.apply_unwatch(ctx, user, reason)
+
+ async def apply_watch(self, ctx: Context, user: FetchedMember, reason: str) -> None:
+ """Handles adding a user to the watch list."""
if user.bot:
await ctx.send(f":x: I'm sorry {ctx.author}, I'm afraid I can't do that. I only watch humans.")
return
@@ -90,10 +100,8 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
await ctx.send(msg)
- @bigbrother_group.command(name='unwatch', aliases=('uw',))
- @with_role(*MODERATION_ROLES)
- async def unwatch_command(self, ctx: Context, user: FetchedMember, *, reason: str) -> None:
- """Stop relaying messages by the given `user`."""
+ async def apply_unwatch(self, ctx: Context, user: FetchedMember, reason: str, banned: bool = False) -> None:
+ """Handles the actual user removal from the watch list."""
active_watches = await self.bot.api_client.get(
self.api_endpoint,
params=ChainMap(
@@ -111,8 +119,10 @@ class BigBrother(WatchChannel, Cog, name="Big Brother"):
await post_infraction(ctx, user, 'watch', f"Unwatched: {reason}", hidden=True, active=False)
- await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.")
+ if not banned: # Prevents a message being sent to the channel if part of a permanent ban
+ await ctx.send(f":white_check_mark: Messages sent by {user} will no longer be relayed.")
self._remove_user(user.id)
else:
- await ctx.send(":x: The specified user is currently not being watched.")
+ if not banned: # Prevents a message being sent to the channel if part of a permanent ban
+ await ctx.send(":x: The specified user is currently not being watched.")