Skip to content

Commit

Permalink
fix: escape markdown for certain parts of bullets
Browse files Browse the repository at this point in the history
  • Loading branch information
AstreaTSS committed Nov 8, 2024
1 parent a4b40ec commit 964c4a9
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions common/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@
)
from pydantic import field_serializer, field_validator

import common.text_utils as text_utils


# yes, this is a copy from common.utils
# but circular imports are a thing
Expand Down Expand Up @@ -91,8 +93,16 @@ def chan_mention(self) -> str:

def bullet_info(self) -> str:
str_list = [
f"Trigger `{self.trigger}` - in {self.chan_mention}",
f"Aliases: {', '.join(f'`{a}`' for a in self.aliases)}",
(
f"Trigger `{text_utils.escape_markdown(self.trigger)}` - in"
f" {self.chan_mention}"
),
(
"Aliases:"
f" {', '.join(f'`{text_utils.escape_markdown(a)}`' for a in self.aliases)}"
if self.aliases
else "N/A"
),
f"Hidden: {yesno_friendly_str(self.hidden)}",
f"Found: {yesno_friendly_str(self.found)}",
]
Expand All @@ -114,7 +124,8 @@ def found_embed(self, username: str, singular_bullet: str) -> ipy.Embed:
color=int(os.environ["BOT_COLOR"]),
)
embed.description = (
f"`{self.trigger}` - from {self.chan_mention}\n\n{self.description}"
f"`{text_utils.escape_markdown(self.trigger)}` - from"
f" {self.chan_mention}\n\n{self.description}"
)

footer = f"Found by {username}" if self.finder else "To be found as of"
Expand Down

0 comments on commit 964c4a9

Please sign in to comment.