feat: duplicate message scanner bot #479
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description: This pull-request resolves #15 by having a bot delete all duplicate messages except the original channel and send a warning in each channel that lasts about 30 seconds.
To reduce memory consumption, a LRU cache is used and some size restrictions. Currently, Discord has a max of 2000 characters limit per message. The worst case scenario the size of this will be ~2MB; Max size of cache is 100 * max set size 5 storing messages * 2 bytes per character * 2000 max characters from Discord = 2MB. Though this cache last for 30 seconds before clearing again.
Realistically, the average message containing 500 characters would be 500 × 1 KB = ~500 KB for the cache memory consumption.
Also, a test file was created to test the feature and the caching. A dependency, shoehorn, was installed to help with the tests' mockup.