aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Akarys42 <[email protected]>2019-10-25 18:43:27 +0200
committerGravatar Akarys42 <[email protected]>2019-10-25 18:43:27 +0200
commitf67378c77a45c581c57d1dfdd5a704319e83ba3a (patch)
tree89b61923946b89dcf98860b1010cd4cc5f7d9db1
parentMove offensive message delete time to config file. (diff)
Remove the possibility that we send a message to the API that the filter has already deleted.
-rw-r--r--bot/cogs/filtering.py30
1 files changed, 15 insertions, 15 deletions
diff --git a/bot/cogs/filtering.py b/bot/cogs/filtering.py
index f9aee5a9a..ea6919707 100644
--- a/bot/cogs/filtering.py
+++ b/bot/cogs/filtering.py
@@ -185,21 +185,6 @@ class Filtering(Cog):
triggered = await _filter["function"](msg)
if triggered:
- # If the message is classed as offensive, we store it in the site db and
- # it will be deleted it after one week.
- if _filter["offensive_msg"]:
- delete_date = msg.created_at.date() + OFFENSIVE_MSG_DELETE_TIME
- await self.bot.api_client.post(
- 'bot/offensive-message',
- json={
- 'id': msg.id,
- 'channel_id': msg.channel.id,
- 'delete_date': delete_date.isoformat()
- }
- )
- log.trace(f"Offensive message will be deleted on "
- f"{delete_date.isoformat()}")
-
# If this is a filter (not a watchlist), we should delete the message.
if _filter["type"] == "filter":
try:
@@ -216,6 +201,21 @@ class Filtering(Cog):
except discord.errors.NotFound:
return
+ # If the message is classed as offensive, we store it in the site db and
+ # it will be deleted it after one week.
+ if _filter["offensive_msg"]:
+ delete_date = msg.created_at.date() + OFFENSIVE_MSG_DELETE_TIME
+ await self.bot.api_client.post(
+ 'bot/offensive-message',
+ json={
+ 'id': msg.id,
+ 'channel_id': msg.channel.id,
+ 'delete_date': delete_date.isoformat()
+ }
+ )
+ log.trace(f"Offensive message will be deleted on "
+ f"{delete_date.isoformat()}")
+
# Notify the user if the filter specifies
if _filter["user_notification"]:
await self.notify_member(msg.author, _filter["notification_msg"], msg.channel)