aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Numerlor <[email protected]>2019-12-31 23:51:46 +0100
committerGravatar Numerlor <[email protected]>2019-12-31 23:51:46 +0100
commit90b8a8fb8b5a32169ddc1d331eaa38d9c6bf270e (patch)
treec4548a37327c92242caabd995465ab91a7d0a3c3
parentMerge pull request #712 from python-discord/audio-whitelist (diff)
Make sure description is truncated to max 1000 chars
Diffstat (limited to '')
-rw-r--r--bot/cogs/doc.py10
1 files changed, 8 insertions, 2 deletions
diff --git a/bot/cogs/doc.py b/bot/cogs/doc.py
index 9506b195a..c1bb4ad41 100644
--- a/bot/cogs/doc.py
+++ b/bot/cogs/doc.py
@@ -307,8 +307,15 @@ class Doc(commands.Cog):
if len(description) > 1000:
shortened = description[:1000]
last_paragraph_end = shortened.rfind('\n\n', 100)
+ # Search the shortened version for cutoff points in decreasing desirability,
+ # cutoff at 1000 if none are found.
if last_paragraph_end == -1:
- last_paragraph_end = shortened.rfind('. ')
+ for string in (". ", ", ", ",", " "):
+ last_paragraph_end = shortened.rfind(string)
+ if last_paragraph_end != -1:
+ break
+ else:
+ last_paragraph_end = 1000
description = description[:last_paragraph_end]
# If there is an incomplete code block, cut it out
@@ -318,7 +325,6 @@ class Doc(commands.Cog):
description += f"... [read more]({permalink})"
description = WHITESPACE_AFTER_NEWLINES_RE.sub('', description)
-
if signatures is None:
# If symbol is a module, don't show signature.
embed_description = description