diff options
| author | 2021-01-11 02:10:35 +0100 | |
|---|---|---|
| committer | 2021-01-11 02:21:32 +0100 | |
| commit | 8d927ff13e0fd93e80102b43c2568f1e74a29a7c (patch) | |
| tree | 7cce51533a08fd1069afeba096d440f2c163914c | |
| parent | Use a dictionary of lists instead of set for renamed symbols (diff) | |
Ensure footer fits into message
The footer also now says Moved: at the start to clarify the meaning
of the symbols to the user
| -rw-r--r-- | bot/exts/info/doc/_cog.py | 7 | ||||
| -rw-r--r-- | bot/exts/info/doc/_parsing.py | 4 |
2 files changed, 8 insertions, 3 deletions
diff --git a/bot/exts/info/doc/_cog.py b/bot/exts/info/doc/_cog.py index deef37f8f..b8c1a10d4 100644 --- a/bot/exts/info/doc/_cog.py +++ b/bot/exts/info/doc/_cog.py @@ -4,6 +4,7 @@ import asyncio import logging import re import sys +import textwrap from collections import defaultdict from contextlib import suppress from types import SimpleNamespace @@ -266,7 +267,11 @@ class DocCog(commands.Cog): description=markdown ) # Show all symbols with the same name that were renamed in the footer. - embed.set_footer(text=", ".join(self.renamed_symbols[symbol])) + if renamed_symbols := self.renamed_symbols[symbol]: + footer_text = f"Moved: {textwrap.shorten(', '.join(renamed_symbols), 100, placeholder=' ...')}" + else: + footer_text = "" + embed.set_footer(text=footer_text) return embed @commands.group(name='docs', aliases=('doc', 'd'), invoke_without_command=True) diff --git a/bot/exts/info/doc/_parsing.py b/bot/exts/info/doc/_parsing.py index f07b530c1..45a81a4cb 100644 --- a/bot/exts/info/doc/_parsing.py +++ b/bot/exts/info/doc/_parsing.py @@ -33,8 +33,8 @@ _NO_SIGNATURE_GROUPS = { _EMBED_CODE_BLOCK_LINE_LENGTH = 61 # _MAX_SIGNATURE_AMOUNT code block wrapped lines with py syntax highlight _MAX_SIGNATURES_LENGTH = (_EMBED_CODE_BLOCK_LINE_LENGTH + 8) * MAX_SIGNATURE_AMOUNT -# Maximum discord message length - signatures on top -_MAX_DESCRIPTION_LENGTH = 2000 - _MAX_SIGNATURES_LENGTH +# Maximum discord message length - signatures on top - space for footer +_MAX_DESCRIPTION_LENGTH = 1900 - _MAX_SIGNATURES_LENGTH _TRUNCATE_STRIP_CHARACTERS = "!?:;." + string.whitespace BracketPair = namedtuple("BracketPair", ["opening_bracket", "closing_bracket"]) |