Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,22 @@ jobs:
chmod +x telegram-bot-api-binary
./telegram-bot-api-binary --api-id=21724 --api-hash=3e0cb5efcd52300aec5994fdfc5bdc16 --local 2>&1 > /dev/null &
curl https://raw.githubusercontent.com/PreviousAlone/ActionScript/main/uploadCI.py -o uploadCI.py
# Legacy Telegram Markdown (used by uploadCI.py) fails with
# "can't parse entities" when the commit body contains backticks —
# they clash with the ``` fence the template wraps the message in.
# Strip them (and any CR) before passing to the uploader.
sanitized=$(printf '%s' "$COMMIT_MESSAGE" | tr -d '`\r')
# Normalise COMMIT_MESSAGE for the Telegram uploader:
# 1. Strip backticks — legacy Markdown parse_mode trips on
# "can't parse entities" when the commit body contains them
# because they collide with the ``` fence in the template.
# 2. Cap length — sendDocument caption limit is 1024 chars;
# template + version adds ~120, so truncate the body to 800
# to leave headroom and avoid HTTP 400.
sanitized=$(python3 <<'PY'
import os
s = os.environ["COMMIT_MESSAGE"].replace("`", "").replace("\r", "")
MAX = 800
if len(s) > MAX:
s = s[:MAX].rstrip() + "\n…(truncated)"
Comment on lines +167 to +168

Copilot AI Apr 19, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The truncation logic can produce a string longer than MAX because it slices to MAX and then appends the "…(truncated)" suffix. If the goal is to cap the commit body at 800 chars to guarantee headroom for Telegram’s 1024 caption limit, consider ensuring the final string length (including the suffix/newline) is <= MAX (or adjust the comment/constant to match the actual maximum output).

Suggested change
if len(s) > MAX:
s = s[:MAX].rstrip() + "\n…(truncated)"
suffix = "\n…(truncated)"
if len(s) > MAX:
keep = MAX - len(suffix)
if keep > 0:
s = s[:keep].rstrip() + suffix
else:
s = suffix[:MAX]

Copilot uses AI. Check for mistakes.
print(s)
PY
)
COMMIT_MESSAGE="$sanitized" python uploadCI.py
env:
CHAT_ID: ${{ secrets.TELEGRAM_CHATID }}
Expand Down
Loading