aboutsummaryrefslogtreecommitdiffstats
path: root/tests/helpers.py (unfollow)
Commit message (Collapse)AuthorLines
2021-08-21Fix MessageCache slicing bugs, improve testsGravatar mbaruh-26/+41
2021-08-21Identify DeletionContext by members, not channelsGravatar mbaruh-17/+14
Since the anti-spam now works cross-channels, it makes no sense to identify it by the channel in which it was invoked. The DeletionContext class was changed to accept a frozenset of members, and the message_deletion_queue dict uses the frozensets as keys. DeletionContext still accepts a channel on creation, because while it might get added more channels, there's only one channel in which the mute message will be sent. Using members as the key can run into the issue of one member becoming irrelevant to the filter while others still are, resulting in another log message being sent, but it's an unlikely edge case since the users should be muted almost immediately, and we're currently not using any multi-member filters in the first place.
2021-08-21AntiSpam deletes from all spammed channelsGravatar mbaruh-7/+16
The anti-spam cog was amended to handle cross-channel spam.
2021-08-21AntiSpam modified to work with cacheGravatar mbaruh-9/+406
The anti-spam cog now uses a cache instead of reading channel history. The cache is for all channels in the guild, and does not remove deleted messages. That means that the anti-spam logic now works cross-channel and counts deleted messages. The size of the cache is determined via a new field in the config YAML file. The cache was implemented as a separate class, MessageCache, which uses circular buffer logic. This allows for constant time addition and removal form either side, and lookup. The cache does not support removal from the middle of the cache. The cache additionally stores a mapping from message ID's to the index of the message in the cache, to allow constant time lookup by message ID. The commit additionally adds accompanying tests, and renames `cache.py` to `caching.py` to better distinguish it from the new `message_cache.py` and convey that it's for general caching utilities.
2021-08-17Move max_interval to initGravatar Boris Muratov-8/+8
The on_message event calculated the max interval value every time for no reason. The value is constant throughout the bot's up time.
2021-08-16HelpChannels: use utility method to get available channelsGravatar MarkKoz-3/+1
2021-08-16Improve output message consistency in webhook_removerGravatar D0rs4n-1/+1
Co-authored-by: Bluenix <[email protected]>
2021-08-16Patch the regEx pattern in webhook_remover to match edge casesGravatar D0rs4n-1/+4
The regEx pattern did not match the 'https://' part in case of canary urls Thus, from now on the regEx pattern matches the full canary urls as well.
2021-08-16Fix up, and improve code consistency in webhook_removerGravatar D0rs4n-2/+2
2021-08-16Remove the admins mention from the modmail tagGravatar wookie184-1/+1
2021-08-16Improve code consistency in webhook_removerGravatar D0rs4n-9/+7
2021-08-15HelpChannels: simplify formatting of category names in dormant msgGravatar MarkKoz-9/+6
Remove redundant retrieval of category objects. Include the asking guide URL in the message via an f-string.
2021-08-15HelpChannels: fix incomplete init of available channel setGravatar MarkKoz-5/+4
If the cog is reloaded while there are less than the maximum amount of available channels, it makes some channels available until the limit is reached. When a channel is made available, it updates the `available_help_channels` set. The `update_available_help_channels()` function would not update this set if it saw that the set already contains elements. This resulted in only the channels that were just made available being in the set; the set would not contain the channels that were already available when the bot started. Fix this by unconditionally populating the set, but moving it to `init_available()` so it only happens once. Fix BOT-Z1 Fix #1715
2021-08-16Enhance security in the Webhook remover.Gravatar D0rs4n-6/+14
From now on, webhooks that were posted in the chat will be also deleted from Discord in order to eliminate the risk.
2021-08-15Add `cj end` timeout message, improve styleGravatar mbaruh-1/+2
Co-authored-by: Bluenix <[email protected]>
2021-08-15Add team name to audit log reasonGravatar mbaruh-1/+5
Interestingly enough, the reason doesn't seem to be displayed for channel permission overrides.
2021-08-15Docstring correctionsGravatar mbaruh-4/+4
Co-authored-by: Bluenix <[email protected]>
2021-08-15Add default value to csv_fileGravatar Boris Muratov-1/+1
Co-authored-by: Bluenix <[email protected]>
2021-08-12fix: Nomination message now checks historic and new style nominationsGravatar Chris Lovering-8/+10
Previously nomination messages had role pings in them, now they don't as we moved them into a thread. Due to this, we need to detect both in the interim of historic nominations existing. A 'proper' fix for this is to store the nomination message IDs when we post them against the nomination object in the site api. We are planing to work on this soon, this commit is a short term fix.
2021-08-11Remove role pings when a helper vote is posted (#1744)Gravatar ChrisJL-2/+2
2021-08-11Remove added punctuation from reminderGravatar TizzySaurus-1/+1
2021-08-11Fetch dormant category rather than use channel.categoryGravatar TizzySaurus-1/+2
channel.category doesn't get updated in cache so the category ends up still linking to "In Use", whereas we want the "Dormant".
2021-08-11Change bot.get_channel to utils.channels.try_get_channelGravatar TizzySaurus-1/+1
2021-08-11Make DORMANT_MSG a string instead of f-stringGravatar TizzySaurus-1/+1
2021-08-11Update embed sent when channel moves to dormant categoryGravatar TizzySaurus-1/+8
2021-08-11Update DORMANT_MSG to allow kwargs in str.format()Gravatar TizzySaurus-3/+3
2021-08-11Update DORMANT_MSG to be compatible with str.format()Gravatar TizzySaurus-3/+3
2021-08-10chore: remove some newlines in the blocking tagGravatar vcokltfre-5/+0
2021-08-09Fixed error message to match true valueGravatar stalkerx-1/+1
When the limit was raised, the error message was not edited to reflect the change. https://github.com/python-discord/bot/commit/6f45d6896adb3f05962733cec8e5db199def20bc
2021-08-08change dockerfile python version to latest 3.9.xGravatar aru-1/+1
2021-08-07Duck pond: abort if reaction's message or author can't be foundGravatar MarkKoz-1/+7
Fixes BOT-1J7
2021-08-07Code block: catch 404s when editing or deleting the messageGravatar MarkKoz-7/+10
Fixes BOT-J2
2021-08-07Incidents: catch 404sGravatar MarkKoz-4/+20
Fixes BOT-ZN
2021-08-04Reorder user roles in !user command from highest to lowest (#1719)Gravatar Objectivitix-1/+3
Reorder user roles in !user command from highest to lowest
2021-08-04Suppress 403 error when sending DEFCON reject DM (#1711)Gravatar Mark-3/+5
403 occurs if the user has DMs disabled. Fixes BOT-137
2021-08-03Force utf-8 decoding when querying metabaseGravatar Chris Lovering-2/+2
Some discord usernames contain unicode characters, which causes an decoding error as chardet isn't 100% and can't falsely detect the response text as Windows-1254.
2021-08-03CodeSnippets: don't send snippets if the original message was deletedGravatar MarkKoz-3/+7
Fixes BOT-13B
2021-08-03CodeSnippets: refactor snippet parsing into a separate functionGravatar MarkKoz-8/+12
2021-08-03CodeSnippets: move __init__ to the top of the class definitionGravatar MarkKoz-11/+11
2021-08-03CodeSnippets: refactor on_messageGravatar MarkKoz-35/+38
Reduce nesting and code duplication.
2021-08-03Add comment on RedisCacheGravatar wookie184-0/+2
2021-08-03Update Sentry SDK to 1.3Gravatar MarkKoz-78/+131
2021-08-03Correctly delete from cacheGravatar Boris Muratov-1/+2
* Fixed wrong condition in rescheduler which made the eventual consistency not work. * Mods now correctly removed from cache on role reapplies.
2021-08-03Add check for redundant changeGravatar wookie184-0/+8
2021-08-03Remove bot prefix from docstring and change single quotes to doubleGravatar wookie184-11/+11