15 lines
332 B
Python
15 lines
332 B
Python
|
|
import logging
|
||
|
|
import re
|
||
|
|
|
||
|
|
logger = logging.getLogger(__name__)
|
||
|
|
|
||
|
|
_MENTION_PATTERN = re.compile(r"@(\w+)")
|
||
|
|
|
||
|
|
|
||
|
|
def extract_mentions_from_text(text: str) -> list[str]:
|
||
|
|
return [m.group(1) for m in _MENTION_PATTERN.finditer(text)]
|
||
|
|
|
||
|
|
|
||
|
|
def build_mention_text(user_name: str, user_id: str | None = None) -> str:
|
||
|
|
return f"@{user_name}"
|