Closed rm-rf-tux closed 1 month ago
This pull request fixes a critical bug in the GIF ratelimiter cog that was preventing the removal of old GIF timestamps and blocking the sending of GIFs. The changes include optimizing the message handling logic, improving the old GIF removal process, and enhancing code readability.
sequenceDiagram
participant U as User
participant B as Bot
participant GL as GifLimiter
U->>B: Send message
B->>GL: on_message
GL->>GL: _should_process_message
alt Contains GIF and not in excluded channel
GL->>GL: _handle_gif_message
alt Exceeds channel limit
GL->>B: Delete message
else Exceeds user limit
GL->>B: Delete message
else Within limits
GL->>GL: Update recent GIFs
end
end
sequenceDiagram
participant GL as GifLimiter
participant T as Time
GL->>T: Get current time
loop For each channel
GL->>GL: Remove old timestamps
end
loop For each user
GL->>GL: Remove old timestamps
alt No recent GIFs
GL->>GL: Delete user entry
end
end
Change | Details | Files |
---|---|---|
Fixed the old GIF timestamp removal logic |
|
tux/cogs/services/gif_limiter.py |
Optimized message handling logic |
|
tux/cogs/services/gif_limiter.py |
Improved code readability and formatting |
|
tux/cogs/services/gif_limiter.py |
Description
This PR is a bug fix in the GIF limiter cog, causing old GIF timestamps to never be removed and preventing the sending of GIFs completely. (I have also removed a useless check in the message handler function.)
Guidelines
My code follows the style guidelines of this project (formatted with Ruff)
I have performed a self-review of my own code
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation if needed
My changes generate no new warnings
I have tested this change
Any dependent changes have been merged and published in downstream modules
I have added all appropriate labels to this PR
[x] I have followed all of these guidelines.
How Has This Been Tested? (if applicable)
Tested in the atl.dev Discord server, with extra debug statements to be absolutely sure everything works
Summary by Sourcery
Fix a critical bug in the GIF limiter cog that caused old GIF timestamps to persist, preventing GIFs from being sent, and remove an unnecessary check in the message handler function.
Bug Fixes:
Enhancements: