diff options
| author | 2019-02-08 17:12:07 +0100 | |
|---|---|---|
| committer | 2019-02-08 17:12:07 +0100 | |
| commit | 9517f16e6d862bc0e83619306af6cadbc9e61b71 (patch) | |
| tree | 8ef385d41e5d61a9b5b60fcac7eb60cf47c82936 | |
| parent | Merge pull request #285 from python-discord/newline-antispam (diff) | |
Adding mandatory unwatch reason for both bb and talent-pool
| -rw-r--r-- | bot/cogs/alias.py | 10 | ||||
| -rw-r--r-- | bot/cogs/bigbrother.py | 14 |
2 files changed, 16 insertions, 8 deletions
diff --git a/bot/cogs/alias.py b/bot/cogs/alias.py index 0e6b3a7c6..23562ad25 100644 --- a/bot/cogs/alias.py +++ b/bot/cogs/alias.py @@ -74,20 +74,18 @@ class Alias: self, ctx: Context, user: User, *, reason: str ): """ - Alias for invoking <prefix>bigbrother watch user [text_channel]. + Alias for invoking <prefix>bigbrother watch user reason. """ await self.invoke(ctx, "bigbrother watch", user, reason=reason) @command(name="unwatch", hidden=True) - async def bigbrother_unwatch_alias(self, ctx, user: User): + async def bigbrother_unwatch_alias(self, ctx, user: User, *, reason: str): """ - Alias for invoking <prefix>bigbrother unwatch user. - - user: discord.User - A user instance to unwatch + Alias for invoking <prefix>bigbrother unwatch user reason. """ - await self.invoke(ctx, "bigbrother unwatch", user) + await self.invoke(ctx, "bigbrother unwatch", user, reason=reason) @command(name="home", hidden=True) async def site_home_alias(self, ctx): diff --git a/bot/cogs/bigbrother.py b/bot/cogs/bigbrother.py index f07289985..caf194b4c 100644 --- a/bot/cogs/bigbrother.py +++ b/bot/cogs/bigbrother.py @@ -355,8 +355,12 @@ class BigBrother: @bigbrother_group.command(name='unwatch', aliases=('uw',)) @with_role(Roles.owner, Roles.admin, Roles.moderator) - async def unwatch_command(self, ctx: Context, user: User): - """Stop relaying messages by the given `user`.""" + async def unwatch_command(self, ctx: Context, user: User, *, reason: str): + """ + Stop relaying messages by the given `user`. + + A `reason` for unwatching is required, which will be added as a note to the user. + """ url = f"{URLs.site_bigbrother_api}?user_id={user.id}" async with self.bot.http_session.delete(url, headers=self.HEADERS) as response: @@ -364,14 +368,20 @@ class BigBrother: await ctx.send(f":ok_hand: will no longer relay messages sent by {user}") if user.id in self.watched_users: + channel = self.watched_users[user.id] + del self.watched_users[user.id] if user.id in self.channel_queues: del self.channel_queues[user.id] if user.id in self.watch_reasons: del self.watch_reasons[user.id] else: + channel = None log.warning(f"user {user.id} was unwatched but was not found in the cache") + reason = f"Unwatched ({channel.name if channel else 'unknown channel'}): {reason}" + await post_infraction(ctx, user, type="warning", reason=reason, hidden=True) + else: data = await response.json() reason = data.get('error_message', "no message provided") |