Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
b2367b2
rework clean to fully use `delete_messages` instead of `purge`
Senjan21 Nov 22, 2020
7bcc74f
rename command `messages` to `until`
Senjan21 Nov 22, 2020
3797474
Introduce cache to cleaning as well as fix cancel
Senjan21 Feb 23, 2021
0a7c728
Implement range clean command
Senjan21 Feb 23, 2021
bb26ed3
set `self.cleaning` to False once done cleaning
Senjan21 Feb 24, 2021
4fcdfb0
Merge remote-tracking branch 'origin/master' into cleanrework
Senjan21 Mar 2, 2021
065787f
Merge remote-tracking branch 'origin/master' into cleanrework
Senjan21 Mar 4, 2021
26c60c1
Change typing, remove `range` alias
Senjan21 Mar 4, 2021
7e74bb3
swap predicate save order for correct deletion
Senjan21 Apr 15, 2021
7e40650
Merge branch 'main' into cleanrework
Senjan21 Apr 15, 2021
11be166
replace lambda with list in defaultdict
Senjan21 Apr 16, 2021
5bf42c7
Use correct kwarg for channel.history
Senjan21 Apr 16, 2021
add0781
simplify use_cache var
Senjan21 Apr 16, 2021
477810f
Naming changes for better self documentation
Senjan21 Apr 16, 2021
708063c
make predicate_range inclusive
Senjan21 Apr 16, 2021
c270549
Better response wording, added alias
Senjan21 Apr 16, 2021
6c9e4f5
Don't delete invocation in mod channel
Senjan21 Apr 16, 2021
e5e4343
document snowflake check better
Senjan21 Apr 16, 2021
1d08b29
Merge branch 'main' into cleanrework
ChrisLovering Jul 26, 2021
12f3c40
Update _get_messages_from_channels return type
ChrisLovering Jul 26, 2021
02b3c8a
Make is_older_than_14d a static method
ChrisLovering Jul 26, 2021
0cc135d
Return empty containers if clean is cancelled
ChrisLovering Jul 28, 2021
770528c
simplify range predicate for clean command
ChrisLovering Jul 28, 2021
ed35227
Rely on error handler for sending input errors to user
ChrisLovering Jul 28, 2021
b2e76dd
Fix references to kwarg after renaming in clean command
ChrisLovering Jul 28, 2021
367cf10
Merge branch 'main' into cleanrework
mbaruh Aug 27, 2021
97aa87a
Moved clean cog to moderation ext
mbaruh Aug 27, 2021
2b5a531
Move clean logging to a helper function
mbaruh Aug 27, 2021
841a148
Move setting cleaning flag to correct line
mbaruh Aug 27, 2021
8aeec5f
Correct logging comment
mbaruh Aug 27, 2021
33e0501
Change `from-to` primary name to `between`
mbaruh Aug 27, 2021
f9d2e69
Don't delete clean cancel embed in mod channel
mbaruh Aug 27, 2021
d81b550
Change cache usage
mbaruh Aug 28, 2021
4334988
Rename "amount" argument to "traverse"
mbaruh Aug 28, 2021
be9bce4
Refactor code, correct logging
mbaruh Aug 28, 2021
675630a
Add checkmark after command completes in mod channels
mbaruh Aug 28, 2021
7b0cb52
Send message when no messages found
mbaruh Aug 28, 2021
1330820
`until` and `between` overhaul
mbaruh Aug 28, 2021
9f124b9
Restrict until and between to a single channel
mbaruh Aug 29, 2021
ec8f063
Use a cog-wide role check
mbaruh Aug 29, 2021
fee4c0c
Handle reacted message being deleted
mbaruh Aug 29, 2021
ab155fb
Added master command
mbaruh Aug 29, 2021
f2fb9f3
Disallow time range cleaning in multiple channels
mbaruh Aug 31, 2021
3ccb533
Changed regex formatting to wrapped in backticks
mbaruh Aug 31, 2021
f5d7a00
Code and comments polish
mbaruh Sep 6, 2021
ed30eae
Fix regex search
mbaruh Sep 7, 2021
c992b6e
Improve responses
mbaruh Sep 7, 2021
5b8e16b
Fix delete order
mbaruh Sep 7, 2021
e33b4aa
Switch `users` and `traverse` in main command
mbaruh Sep 7, 2021
d9efe01
Fix incorrect cache usage
mbaruh Sep 7, 2021
f4658f8
Handle Regex converter errors
mbaruh Sep 11, 2021
e215fb0
End clean on unexpected errors
mbaruh Sep 11, 2021
c272265
Indentation, type-hint, and documentation fixes
mbaruh Sep 20, 2021
2abab68
Merge branch 'main' into cleanrework
mbaruh Oct 17, 2021
aa66673
Adjust docstring to #1876
mbaruh Oct 25, 2021
b42f148
Apply requested style changes
mbaruh Oct 25, 2021
cae0483
Improve documentation of global variables
mbaruh Oct 25, 2021
21dc906
Merge branch 'main' into cleanrework
mbaruh Oct 25, 2021
37b7a3b
Update Age converter to use TZ aware datetime
mbaruh Oct 25, 2021
d19824d
Remove channel limitation with time range
mbaruh Oct 25, 2021
4b27cdf
Merge branch 'main' into cleanrework
wookie184 Oct 30, 2021
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: 19 additions & 0 deletions bot/converters.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,24 @@ async def convert(self, ctx: Context, duration: str) -> datetime:
raise BadArgument(f"`{duration}` results in a datetime outside the supported range.")


class Age(DurationDelta):
"""Convert duration strings into UTC datetime.datetime objects."""

async def convert(self, ctx: Context, duration: str) -> datetime:
"""
Converts a `duration` string to a datetime object that's `duration` in the past.

The converter supports the same symbols for each unit of time as its parent class.
"""
delta = await super().convert(ctx, duration)
now = datetime.now(timezone.utc)

try:
return now - delta
except (ValueError, OverflowError):
raise BadArgument(f"`{duration}` results in a datetime outside the supported range.")
Comment thread
jchristgit marked this conversation as resolved.


class OffTopicName(Converter):
"""A converter that ensures an added off-topic name is valid."""

Expand Down Expand Up @@ -601,6 +619,7 @@ async def convert(self, ctx: Context, arg: str) -> t.Optional[dict]:
SourceConverter = SourceType # noqa: F811
DurationDelta = relativedelta # noqa: F811
Duration = datetime # noqa: F811
Age = datetime # noqa: F811
OffTopicName = str # noqa: F811
ISODateTime = datetime # noqa: F811
HushDurationConverter = int # noqa: F811
Expand Down
Loading