message_utils

Message utility functions for Discord bot.

Includes markdown-aware message splitting that preserves formatting across chunk boundaries, plus helper functions for mention filtering and XML escaping.

message_utils.escape_xml(text)[source]

Escape XML characters in text to prevent parsing issues.

Return type:

str

Parameters:

text (str)

message_utils.filter_backticks_from_mentions(text)[source]

Remove backticks surrounding Discord user mentions.

Converts patterns like <@82303438955753472> to <@82303438955753472>. Also handles triple-backtick wrapping.

Return type:

str

Parameters:

text (str)

message_utils.split_message(text, max_length=1950, overflow_allowed=45)[source]

Split a string into chunks respecting markdown formatting.

Handles manual split markers ({{ SPLIT_HERE }}, ---\n), code blocks, and active markdown formats (bold, italic, etc.). Formats are closed at the end of each chunk and re-opened at the start of the next so that Discord renders them correctly.

Return type:

List[str]

Parameters:
  • text (str)

  • max_length (int)

  • overflow_allowed (int)