aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar mbaruh <[email protected]>2023-02-28 15:54:30 +0200
committerGravatar mbaruh <[email protected]>2023-02-28 15:54:30 +0200
commitd4926d394fe14a666c238de6e35ef10cabb418e0 (patch)
tree359e42e8f26e28c50b59c95f976126bdcf71cad7
parentDon't allow adding filter lists with no implementation (diff)
Copy message from other infraction if result doesn't have one.
-rw-r--r--bot/exts/filtering/_settings_types/actions/infraction_and_notification.py24
1 files changed, 19 insertions, 5 deletions
diff --git a/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py b/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py
index 389d2b7b9..48249115b 100644
--- a/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py
+++ b/bot/exts/filtering/_settings_types/actions/infraction_and_notification.py
@@ -168,17 +168,20 @@ class InfractionAndNotification(ActionEntry):
There is no clear way to properly combine several notification messages, especially when it's in two parts.
To avoid bombarding the user with several notifications, the message with the more significant infraction
- is used.
+ is used. If the more significant infraction has no accompanying message, use the one from the other infraction,
+ if it exists.
"""
# Lower number -> higher in the hierarchy
if self.infraction_type is None:
return other.copy()
elif other.infraction_type is None:
return self.copy()
- elif self.infraction_type.value < other.infraction_type.value:
- return self.copy()
+
+ if self.infraction_type.value < other.infraction_type.value:
+ result = self.copy()
elif self.infraction_type.value > other.infraction_type.value:
- return other.copy()
+ result = other.copy()
+ other = self
else:
if self.infraction_duration is None or (
other.infraction_duration is not None and self.infraction_duration > other.infraction_duration
@@ -186,4 +189,15 @@ class InfractionAndNotification(ActionEntry):
result = self.copy()
else:
result = other.copy()
- return result
+ other = self
+
+ # If the winner has no message but the loser does, copy the message to the winner.
+ result_overrides = result.overrides
+ if "dm_content" not in result_overrides and "dm_embed" not in result_overrides:
+ other_overrides = other.overrides
+ if "dm_content" in other_overrides:
+ result.dm_content = other_overrides["dm_content"]
+ if "dm_embed" in other_overrides:
+ result.dm_content = other_overrides["dm_embed"]
+
+ return result