Beta/core/utils.py

17 lines
442 B
Python
Raw Normal View History

2026-02-06 22:23:20 +01:00
"""Utility functions for Superviseur bot."""
import re
def format_mentions_in_text(text: str) -> str:
"""Convert user ID numbers in text to Discord mention format <@id>."""
# Match sequences of 15-20 digits
pattern = r'\b(\d{15,20})\b'
return re.sub(pattern, r'<@\1>', text)
def sanitize_guild_name(name: str) -> str:
"""Sanitize guild name for use in file paths."""
return re.sub(r'[\/\\:*?"<>|\s]', '_', name)