mirror of
https://github.com/bmadcode/BMAD-METHOD.git
synced 2025-12-29 16:14:59 +00:00
- Fix esc() bracket expression (] must be first in POSIX regex) - Fix delete job: inline helper to avoid checkout of deleted ref - Fix issue notifications: attribute close/reopen to actor, not author - Simplify trunc() comment (remove false Unicode-safe claim) - Smart truncation with wall-of-text detection - Escape markdown and @mentions for safe display 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Brian <bmadcode@gmail.com>
16 lines
575 B
Bash
16 lines
575 B
Bash
#!/bin/bash
|
|
# Discord notification helper functions
|
|
|
|
# Escape markdown special chars and @mentions for safe Discord display
|
|
# Bracket expression: ] must be first, then other chars. In POSIX bracket expr, \ is literal.
|
|
esc() { sed -e 's/[][\*_()~`>]/\\&/g' -e 's/@/@ /g'; }
|
|
|
|
# Truncate to $1 chars (or 80 if wall-of-text with <3 spaces)
|
|
trunc() {
|
|
local max=$1
|
|
local txt=$(tr '\n\r' ' ' | cut -c1-"$max")
|
|
local spaces=$(printf '%s' "$txt" | tr -cd ' ' | wc -c)
|
|
[ "$spaces" -lt 3 ] && [ ${#txt} -gt 80 ] && txt=$(printf '%s' "$txt" | cut -c1-80)
|
|
printf '%s' "$txt"
|
|
}
|