aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar PureFunctor <[email protected]>2020-11-08 16:03:11 +0800
committerGravatar PureFunctor <[email protected]>2020-11-08 16:10:31 +0800
commitaf7cfd35945f7885a7cd36490aa0ffcf91218c8b (patch)
tree4e85eaace8132426421888b7177f7d460b469ee2
parentRefactor redundant code in infraction_edit (diff)
Automatically add periods as visual buffers
-rw-r--r--bot/exts/moderation/infraction/management.py17
-rw-r--r--bot/utils/regex.py2
2 files changed, 13 insertions, 6 deletions
diff --git a/bot/exts/moderation/infraction/management.py b/bot/exts/moderation/infraction/management.py
index 88b2f98c6..e6513c32d 100644
--- a/bot/exts/moderation/infraction/management.py
+++ b/bot/exts/moderation/infraction/management.py
@@ -16,6 +16,7 @@ from bot.exts.moderation.modlog import ModLog
from bot.pagination import LinePaginator
from bot.utils import messages, time
from bot.utils.checks import in_whitelist_check
+from bot.utils.regex import END_PUNCTUATION_RE
log = logging.getLogger(__name__)
@@ -72,13 +73,17 @@ class ModManagement(commands.Cog):
Use "p" or "permanent" to mark the infraction as permanent. Alternatively, an ISO 8601
timestamp can be provided for the duration.
+
+ If a previous infraction reason does not end with an ending punctuation mark, this automatically
+ adds a period before the amended reason.
"""
- await self.infraction_edit(
- ctx=ctx,
- infraction=infraction,
- duration=duration,
- reason=fr"{infraction['reason']} **\|\|** {reason}",
- )
+ add_period = not END_PUNCTUATION_RE.match(infraction["reason"])
+
+ new_reason = "".join((
+ infraction["reason"], ". " if add_period else " ", reason,
+ ))
+
+ await self.infraction_edit(ctx, infraction, duration, reason=new_reason)
@infraction_group.command(name='edit')
async def infraction_edit(
diff --git a/bot/utils/regex.py b/bot/utils/regex.py
index 0d2068f90..cfce52bb3 100644
--- a/bot/utils/regex.py
+++ b/bot/utils/regex.py
@@ -10,3 +10,5 @@ INVITE_RE = re.compile(
r"([a-zA-Z0-9\-]+)", # the invite code itself
flags=re.IGNORECASE
)
+
+END_PUNCTUATION_RE = re.compile("^.+?[.?!]$")