Skip to content

Add a cog to bump threads#2084

Merged
ChrisLovering merged 3 commits into
mainfrom
thread-bumper-cog
Feb 18, 2022
Merged

Add a cog to bump threads#2084
ChrisLovering merged 3 commits into
mainfrom
thread-bumper-cog

Conversation

@ChrisLovering
Copy link
Copy Markdown
Member

Quite often we want threads such as event discussions, or moderation discussions to live beyond their maximum of 1 week of auto-archival. This cog allows staff to add a thread to a list that will get 'bumped' back open by the bot when they are auto-archived

@ChrisLovering ChrisLovering force-pushed the thread-bumper-cog branch 2 times, most recently from 02e07e3 to 4dda4ca Compare February 13, 2022 22:05
@ChrisLovering ChrisLovering added a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 2 - normal Normal Priority s: needs review Author is waiting for someone to review and approve t: feature New feature or request labels Feb 13, 2022
Copy link
Copy Markdown
Contributor

@vivekashok1221 vivekashok1221 left a comment

Choose a reason for hiding this comment

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

Neat and concise!

Comment thread bot/exts/utils/thread_bumper.py Outdated
@Xithrius Xithrius requested review from HassanAbouelela and removed request for ks129 February 14, 2022 16:14
Comment thread bot/exts/utils/thread_bumper.py Outdated
@ChrisLovering ChrisLovering force-pushed the thread-bumper-cog branch 2 times, most recently from df6c8a4 to a958d6d Compare February 17, 2022 00:32
Comment thread bot/exts/utils/thread_bumper.py
Copy link
Copy Markdown
Contributor

@ToxicKidz ToxicKidz left a comment

Choose a reason for hiding this comment

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

LGTM, works well, :shipit:, just one comment.

Comment thread bot/exts/utils/thread_bumper.py Outdated
Copy link
Copy Markdown
Contributor

@vivekashok1221 vivekashok1221 left a comment

Choose a reason for hiding this comment

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

Two minor suggestions, feel free to ignore if you feel they're not needed.

Comment thread bot/exts/utils/thread_bumper.py Outdated
if not ctx.invoked_subcommand:
await ctx.send_help(ctx.command)

@thread_bump_group.command(name="add")
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.

Suggested change
@thread_bump_group.command(name="add")
@thread_bump_group.command(name="add", aliases=("a",))

How about adding a as an alias to add? Feel free to ignore this comment because add is short as it is, but, personally, I would expect a to be an alias for add since r is an alias for remove.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

else:
raise commands.BadArgument("You must provide a thread, or run this command within a thread.")

await self.threads_to_bump.set(thread.id, "sentinel")
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.

When trying to add a thread which is already in the bump list, it might be useful to send a message like "Thread is already in the bump list. ".

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Copy link
Copy Markdown
Contributor

@vivekashok1221 vivekashok1221 left a comment

Choose a reason for hiding this comment

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

Sorry, but I one more thing I wanted to point out 😅 .

Comment thread bot/exts/utils/thread_bumper.py Outdated
Comment on lines +129 to +136
bumped_threads = [k for k, _ in await self.threads_to_bump.items()]
if after.id in bumped_threads:
await self.unarchive_threads_not_manually_archived([after])
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.

PS: I believe you can do something like this here instead.

Suggested change
bumped_threads = [k for k, _ in await self.threads_to_bump.items()]
if after.id in bumped_threads:
await self.unarchive_threads_not_manually_archived([after])
if await bumped_threads.contains(after.id):
await self.unarchive_threads_not_manually_archived([after])

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.

You could also use RedisCache.contains() in line 88 if you decide to incorporate this suggestion.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Quite often we want threads such as event discussions, or moderation discussions to live beyond their maximum of 1 week of auto-archival. This cog allows staff to add a thread to a list that will get 'bumped' back open by the bot when they are auto-archived
Copy link
Copy Markdown
Contributor

@vivekashok1221 vivekashok1221 left a comment

Choose a reason for hiding this comment

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

LGTM 🌟

@ChrisLovering ChrisLovering merged commit 389cb81 into main Feb 18, 2022
@ChrisLovering ChrisLovering deleted the thread-bumper-cog branch February 18, 2022 21:27
@Xithrius Xithrius removed the s: needs review Author is waiting for someone to review and approve label Feb 20, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

a: utility Related to utility commands: (bot, eval, extensions, jams, reminders, snekbox, utils) p: 2 - normal Normal Priority t: feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants