Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions bot/cogs/watchchannels/bigbrother.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,29 @@ async def bigbrother_group(self, ctx: Context) -> None:

@bigbrother_group.command(name='watched', aliases=('all', 'list'))
@with_role(*MODERATION_ROLES)
async def watched_command(self, ctx: Context, update_cache: bool = True) -> None:
async def watched_command(
self, ctx: Context, oldest_first: bool = False, update_cache: bool = True
) -> None:
"""
Shows the users that are currently being monitored by Big Brother.

The optional kwarg `oldest_first` can be used to order the list by oldest watched.

The optional kwarg `update_cache` can be used to update the user
cache using the API before listing the users.
"""
await self.list_watched_users(ctx, oldest_first=oldest_first, update_cache=update_cache)

@bigbrother_group.command(name='oldest')
@with_role(*MODERATION_ROLES)
async def oldest_command(self, ctx: Context, update_cache: bool = True) -> None:
"""
Shows Big Brother monitored users ordered by oldest watched.

The optional kwarg `update_cache` can be used to update the user
cache using the API before listing the users.
"""
await self.list_watched_users(ctx, update_cache)
await ctx.invoke(self.watched_command, oldest_first=True, update_cache=update_cache)

@bigbrother_group.command(name='watch', aliases=('w',))
@with_role(*MODERATION_ROLES)
Expand Down
19 changes: 17 additions & 2 deletions bot/cogs/watchchannels/talentpool.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,14 +38,29 @@ async def nomination_group(self, ctx: Context) -> None:

@nomination_group.command(name='watched', aliases=('all', 'list'))
@with_role(*MODERATION_ROLES)
async def watched_command(self, ctx: Context, update_cache: bool = True) -> None:
async def watched_command(
self, ctx: Context, oldest_first: bool = False, update_cache: bool = True
) -> None:
"""
Shows the users that are currently being monitored in the talent pool.

The optional kwarg `oldest_first` can be used to order the list by oldest nomination.

The optional kwarg `update_cache` can be used to update the user
cache using the API before listing the users.
"""
await self.list_watched_users(ctx, oldest_first=oldest_first, update_cache=update_cache)

@nomination_group.command(name='oldest')
@with_role(*MODERATION_ROLES)
async def oldest_command(self, ctx: Context, update_cache: bool = True) -> None:
"""
Shows talent pool monitored users ordered by oldest nomination.

The optional kwarg `update_cache` can be used to update the user
cache using the API before listing the users.
"""
await self.list_watched_users(ctx, update_cache)
await ctx.invoke(self.watched_command, oldest_first=True, update_cache=update_cache)

@nomination_group.command(name='watch', aliases=('w', 'add', 'a'))
@with_role(*STAFF_ROLES)
Expand Down
10 changes: 9 additions & 1 deletion bot/cogs/watchchannels/watchchannel.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,14 @@ async def send_header(self, msg: Message) -> None:

await self.webhook_send(embed=embed, username=msg.author.display_name, avatar_url=msg.author.avatar_url)

async def list_watched_users(self, ctx: Context, update_cache: bool = True) -> None:
async def list_watched_users(
self, ctx: Context, oldest_first: bool = False, update_cache: bool = True
) -> None:
Comment on lines +290 to +292
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method signature still fits within 120 chars, is this broken down intentionally? I don't mind it, just wondering.

Additionally, the oldest_first param isn't documented in the docstring (it is in the commands), but I think it's self-explanatory and doesn't need to be mentioned.

"""
Gives an overview of the watched user list for this channel.

The optional kwarg `oldest_first` orders the list by oldest entry.

The optional kwarg `update_cache` specifies whether the cache should
be refreshed by polling the API.
"""
Expand All @@ -305,7 +309,11 @@ async def list_watched_users(self, ctx: Context, update_cache: bool = True) -> N
time_delta = self._get_time_delta(inserted_at)
lines.append(f"• <@{user_id}> (added {time_delta})")

if oldest_first:
lines.reverse()

lines = lines or ("There's nothing here yet.",)

embed = Embed(
title=f"{self.__class__.__name__} watched users ({'updated' if update_cache else 'cached'})",
color=Color.blue()
Expand Down