16 lines
442 B
Python
16 lines
442 B
Python
"""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)
|
|
|