From 0c26bd5f6ef89baf8348ea4792eaa618c824cf92 Mon Sep 17 00:00:00 2001 From: Heistergand Date: Thu, 19 Feb 2026 15:29:01 +0100 Subject: [PATCH 1/5] Fix escaping logic for Telegram notifications Updated escaping logic to remove carriage return characters from issue, comment, and PR body before storing in environment variables. --- .github/workflows/telegram-notifications.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/telegram-notifications.yml b/.github/workflows/telegram-notifications.yml index b6d64ca..f801a09 100644 --- a/.github/workflows/telegram-notifications.yml +++ b/.github/workflows/telegram-notifications.yml @@ -20,21 +20,21 @@ jobs: if: ${{ github.event_name == 'issues' }} run: | ESCAPED_BODY=$(echo "${{ github.event.issue.body }}" | sed 's/&/\&/g; s//\>/g') - echo "ESCAPED_BODY=$ESCAPED_BODY" >> $GITHUB_ENV + echo "ESCAPED_BODY=$(echo "$ESCAPED_BODY" | tr -d '\r')" >> $GITHUB_ENV # --- Escape Comment Body --- - name: Escape Comment Body if: ${{ github.event_name == 'issue_comment' || github.event_name == 'pull_request_review_comment' }} run: | ESCAPED_COMMENT=$(echo "${{ github.event.comment.body }}" | sed 's/&/\&/g; s//\>/g') - echo "ESCAPED_COMMENT=$ESCAPED_COMMENT" >> $GITHUB_ENV + echo "ESCAPED_COMMENT=$(echo "$ESCAPED_COMMENT" | tr -d '\r')" >> $GITHUB_ENV # --- Escape PR Body --- - name: Escape PR Body if: ${{ github.event_name == 'pull_request' }} run: | ESCAPED_PR_BODY=$(echo "${{ github.event.pull_request.body }}" | sed 's/&/\&/g; s//\>/g') - echo "ESCAPED_PR_BODY=$ESCAPED_PR_BODY" >> $GITHUB_ENV + echo "ESCAPED_PR_BODY=$(echo "$ESCAPED_PR_BODY" | tr -d '\r')" >> $GITHUB_ENV # --- Telegram: Issue --- - name: Send Telegram (Issue) From 40c4e73482a8d53bba1cff59006c8b42ea86b22b Mon Sep 17 00:00:00 2001 From: Heistergand Date: Thu, 19 Feb 2026 15:37:05 +0100 Subject: [PATCH 2/5] Create telegram-notifications2.yml --- .github/workflows/telegram-notifications2.yml | 304 ++++++++++++++++++ 1 file changed, 304 insertions(+) create mode 100644 .github/workflows/telegram-notifications2.yml diff --git a/.github/workflows/telegram-notifications2.yml b/.github/workflows/telegram-notifications2.yml new file mode 100644 index 0000000..c1867c2 --- /dev/null +++ b/.github/workflows/telegram-notifications2.yml @@ -0,0 +1,304 @@ +name: Telegram Notifications + +on: + issues: + types: [opened, edited, closed] + issue_comment: + types: [created] + pull_request: + types: [opened, edited, closed, reopened] + pull_request_review_comment: + types: [created] + +jobs: + send_notification: + runs-on: ubuntu-latest + + steps: + # ---------------------------- + # Build message files + # ---------------------------- + + - name: Build Telegram message (Issue) + if: ${{ github.event_name == 'issues' }} + shell: bash + run: | + set -euo pipefail + + ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" + ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" + ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" + ISSUE_BODY_RAW="$(jq -r '.issue.body // ""' "$GITHUB_EVENT_PATH")" + + esc() { + python3 - <<'PY' + import html, sys + text = sys.stdin.read() + text = text.replace("\r\n", "\n").replace("\r", "\n") + if text.strip() == "": + text = "(empty)" + sys.stdout.write(html.escape(text, quote=False)) + PY + } + + truncate_body() { + python3 - <<'PY' + import sys + s = sys.stdin.read() + max_len = 2500 + if len(s) > max_len: + s = s[:max_len] + "\n…(truncated)…" + sys.stdout.write(s) + PY + } + + ISSUE_TITLE="$(printf '%s' "$ISSUE_TITLE_RAW" | esc)" + ISSUE_URL_ESC="$(printf '%s' "$ISSUE_URL" | esc)" + ISSUE_BODY="$(printf '%s' "$ISSUE_BODY_RAW" | esc | truncate_body)" + + cat > tg_issue.html <Issue URL: $ISSUE_URL_ESC + ${GITHUB_ACTOR} triggered issue event: $(printf '%s' "$ACTION" | esc) + Title: $ISSUE_TITLE +
$ISSUE_BODY
+ EOF + + - name: Build Telegram message (Issue Comment) + if: ${{ github.event_name == 'issue_comment' }} + shell: bash + run: | + set -euo pipefail + + ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" + ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" + COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" + COMMENT_BODY_RAW="$(jq -r '.comment.body // ""' "$GITHUB_EVENT_PATH")" + + esc() { + python3 - <<'PY' + import html, sys + text = sys.stdin.read() + text = text.replace("\r\n", "\n").replace("\r", "\n") + if text.strip() == "": + text = "(empty)" + sys.stdout.write(html.escape(text, quote=False)) + PY + } + + truncate_body() { + python3 - <<'PY' + import sys + s = sys.stdin.read() + max_len = 2500 + if len(s) > max_len: + s = s[:max_len] + "\n…(truncated)…" + sys.stdout.write(s) + PY + } + + ISSUE_TITLE="$(printf '%s' "$ISSUE_TITLE_RAW" | esc)" + ISSUE_URL_ESC="$(printf '%s' "$ISSUE_URL" | esc)" + COMMENT_URL_ESC="$(printf '%s' "$COMMENT_URL" | esc)" + COMMENT_BODY="$(printf '%s' "$COMMENT_BODY_RAW" | esc | truncate_body)" + + cat > tg_issue_comment.html <Comment URL: $COMMENT_URL_ESC + Issue URL: $ISSUE_URL_ESC + Issue: $ISSUE_TITLE + ${GITHUB_ACTOR} commented: +
$COMMENT_BODY
+ EOF + + - name: Build Telegram message (Pull Request) + if: ${{ github.event_name == 'pull_request' }} + shell: bash + run: | + set -euo pipefail + + ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" + PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" + PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" + PR_BODY_RAW="$(jq -r '.pull_request.body // ""' "$GITHUB_EVENT_PATH")" + + esc() { + python3 - <<'PY' + import html, sys + text = sys.stdin.read() + text = text.replace("\r\n", "\n").replace("\r", "\n") + if text.strip() == "": + text = "(empty)" + sys.stdout.write(html.escape(text, quote=False)) + PY + } + + truncate_body() { + python3 - <<'PY' + import sys + s = sys.stdin.read() + max_len = 2500 + if len(s) > max_len: + s = s[:max_len] + "\n…(truncated)…" + sys.stdout.write(s) + PY + } + + PR_TITLE="$(printf '%s' "$PR_TITLE_RAW" | esc)" + PR_URL_ESC="$(printf '%s' "$PR_URL" | esc)" + PR_BODY="$(printf '%s' "$PR_BODY_RAW" | esc | truncate_body)" + + cat > tg_pr.html <PR URL: $PR_URL_ESC + ${GITHUB_ACTOR} triggered PR event: $(printf '%s' "$ACTION" | esc) + Title: $PR_TITLE +
$PR_BODY
+ EOF + + - name: Build Telegram message (PR Review Comment) + if: ${{ github.event_name == 'pull_request_review_comment' }} + shell: bash + run: | + set -euo pipefail + + PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" + PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" + COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" + COMMENT_BODY_RAW="$(jq -r '.comment.body // ""' "$GITHUB_EVENT_PATH")" + + esc() { + python3 - <<'PY' + import html, sys + text = sys.stdin.read() + text = text.replace("\r\n", "\n").replace("\r", "\n") + if text.strip() == "": + text = "(empty)" + sys.stdout.write(html.escape(text, quote=False)) + PY + } + + truncate_body() { + python3 - <<'PY' + import sys + s = sys.stdin.read() + max_len = 2500 + if len(s) > max_len: + s = s[:max_len] + "\n…(truncated)…" + sys.stdout.write(s) + PY + } + + PR_TITLE="$(printf '%s' "$PR_TITLE_RAW" | esc)" + PR_URL_ESC="$(printf '%s' "$PR_URL" | esc)" + COMMENT_URL_ESC="$(printf '%s' "$COMMENT_URL" | esc)" + COMMENT_BODY="$(printf '%s' "$COMMENT_BODY_RAW" | esc | truncate_body)" + + cat > tg_pr_comment.html <Comment URL: $COMMENT_URL_ESC + PR URL: $PR_URL_ESC + PR: $PR_TITLE + ${GITHUB_ACTOR} commented: +
$COMMENT_BODY
+ EOF + + # ---------------------------- + # Send (with fallback) + # ---------------------------- + + - name: Send Telegram (Issue) + if: ${{ github.event_name == 'issues' }} + id: tg_issue + continue-on-error: true + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message_file: tg_issue.html + + - name: Send Telegram Fallback (Issue) + if: ${{ github.event_name == 'issues' && steps.tg_issue.outcome == 'failure' }} + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message: | + 🚨 Issue Notification 🚨 +
cannot parse message to telegram
+ + - name: Send Telegram (Issue Comment) + if: ${{ github.event_name == 'issue_comment' }} + id: tg_issue_comment + continue-on-error: true + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message_file: tg_issue_comment.html + + - name: Send Telegram Fallback (Issue Comment) + if: ${{ github.event_name == 'issue_comment' && steps.tg_issue_comment.outcome == 'failure' }} + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message: | + šŸ“ Comment on Issue šŸ“ +
cannot parse message to telegram
+ + - name: Send Telegram (Pull Request) + if: ${{ github.event_name == 'pull_request' }} + id: tg_pr + continue-on-error: true + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message_file: tg_pr.html + + - name: Send Telegram Fallback (Pull Request) + if: ${{ github.event_name == 'pull_request' && steps.tg_pr.outcome == 'failure' }} + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message: | + šŸš€ Pull Request Notification šŸš€ +
cannot parse message to telegram
+ + - name: Send Telegram (PR Review Comment) + if: ${{ github.event_name == 'pull_request_review_comment' }} + id: tg_pr_comment + continue-on-error: true + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message_file: tg_pr_comment.html + + - name: Send Telegram Fallback (PR Review Comment) + if: ${{ github.event_name == 'pull_request_review_comment' && steps.tg_pr_comment.outcome == 'failure' }} + uses: appleboy/telegram-action@v1.0.1 + with: + to: ${{ secrets.TELEGRAM_TO }} + token: ${{ secrets.TELEGRAM_TOKEN }} + format: html + disable_web_page_preview: true + message: | + šŸ’¬ Comment on Pull Request šŸ’¬ +
cannot parse message to telegram
From b8f62b423807704b28ee07996a9dcf68a08b75e2 Mon Sep 17 00:00:00 2001 From: Heistergand Date: Thu, 19 Feb 2026 15:43:51 +0100 Subject: [PATCH 3/5] Update telegram-notifications2.yml --- .github/workflows/telegram-notifications2.yml | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/.github/workflows/telegram-notifications2.yml b/.github/workflows/telegram-notifications2.yml index c1867c2..6b260a6 100644 --- a/.github/workflows/telegram-notifications2.yml +++ b/.github/workflows/telegram-notifications2.yml @@ -1,4 +1,4 @@ -name: Telegram Notifications +name: Telegram Notifications v2 on: issues: @@ -23,8 +23,7 @@ jobs: if: ${{ github.event_name == 'issues' }} shell: bash run: | - set -euo pipefail - + ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" @@ -68,8 +67,7 @@ jobs: if: ${{ github.event_name == 'issue_comment' }} shell: bash run: | - set -euo pipefail - + ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" @@ -115,8 +113,7 @@ jobs: if: ${{ github.event_name == 'pull_request' }} shell: bash run: | - set -euo pipefail - + ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" @@ -160,8 +157,7 @@ jobs: if: ${{ github.event_name == 'pull_request_review_comment' }} shell: bash run: | - set -euo pipefail - + PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" From 7a2cea90935c27825d615a0625358ee4fa299d42 Mon Sep 17 00:00:00 2001 From: Heistergand Date: Thu, 19 Feb 2026 16:03:36 +0100 Subject: [PATCH 4/5] Update telegram-notifications2.yml --- .github/workflows/telegram-notifications2.yml | 317 +++++------------- 1 file changed, 78 insertions(+), 239 deletions(-) diff --git a/.github/workflows/telegram-notifications2.yml b/.github/workflows/telegram-notifications2.yml index 6b260a6..659270b 100644 --- a/.github/workflows/telegram-notifications2.yml +++ b/.github/workflows/telegram-notifications2.yml @@ -1,4 +1,4 @@ -name: Telegram Notifications v2 +name: Telegram Notifications on: issues: @@ -13,288 +13,127 @@ on: jobs: send_notification: runs-on: ubuntu-latest - steps: - # ---------------------------- - # Build message files - # ---------------------------- - - name: Build Telegram message (Issue) if: ${{ github.event_name == 'issues' }} shell: bash + env: + BODY: ${{ github.event.issue.body }} run: | - - ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" - ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" - ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" - ISSUE_BODY_RAW="$(jq -r '.issue.body // ""' "$GITHUB_EVENT_PATH")" - - esc() { - python3 - <<'PY' - import html, sys - text = sys.stdin.read() - text = text.replace("\r\n", "\n").replace("\r", "\n") - if text.strip() == "": - text = "(empty)" - sys.stdout.write(html.escape(text, quote=False)) - PY - } + ESCAPED_BODY=$(printf '%s' "$BODY" \ + | tr -d '\r' \ + | sed -e 's/&/\&/g' -e 's//\>/g') - truncate_body() { - python3 - <<'PY' - import sys - s = sys.stdin.read() - max_len = 2500 - if len(s) > max_len: - s = s[:max_len] + "\n…(truncated)…" - sys.stdout.write(s) - PY - } - - ISSUE_TITLE="$(printf '%s' "$ISSUE_TITLE_RAW" | esc)" - ISSUE_URL_ESC="$(printf '%s' "$ISSUE_URL" | esc)" - ISSUE_BODY="$(printf '%s' "$ISSUE_BODY_RAW" | esc | truncate_body)" - - cat > tg_issue.html < tg_message.html <<'EOF' 🚨 Issue Notification 🚨 - Issue URL: $ISSUE_URL_ESC - ${GITHUB_ACTOR} triggered issue event: $(printf '%s' "$ACTION" | esc) - Title: $ISSUE_TITLE -
$ISSUE_BODY
- EOF - - - name: Build Telegram message (Issue Comment) - if: ${{ github.event_name == 'issue_comment' }} - shell: bash - run: | - - ISSUE_URL="$(jq -r '.issue.html_url // ""' "$GITHUB_EVENT_PATH")" - ISSUE_TITLE_RAW="$(jq -r '.issue.title // ""' "$GITHUB_EVENT_PATH")" - COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" - COMMENT_BODY_RAW="$(jq -r '.comment.body // ""' "$GITHUB_EVENT_PATH")" - - esc() { - python3 - <<'PY' - import html, sys - text = sys.stdin.read() - text = text.replace("\r\n", "\n").replace("\r", "\n") - if text.strip() == "": - text = "(empty)" - sys.stdout.write(html.escape(text, quote=False)) - PY - } - - truncate_body() { - python3 - <<'PY' - import sys - s = sys.stdin.read() - max_len = 2500 - if len(s) > max_len: - s = s[:max_len] + "\n…(truncated)…" - sys.stdout.write(s) - PY - } - - ISSUE_TITLE="$(printf '%s' "$ISSUE_TITLE_RAW" | esc)" - ISSUE_URL_ESC="$(printf '%s' "$ISSUE_URL" | esc)" - COMMENT_URL_ESC="$(printf '%s' "$COMMENT_URL" | esc)" - COMMENT_BODY="$(printf '%s' "$COMMENT_BODY_RAW" | esc | truncate_body)" - - cat > tg_issue_comment.html <Comment URL: $COMMENT_URL_ESC - Issue URL: $ISSUE_URL_ESC - Issue: $ISSUE_TITLE - ${GITHUB_ACTOR} commented: -
$COMMENT_BODY
EOF - - name: Build Telegram message (Pull Request) - if: ${{ github.event_name == 'pull_request' }} - shell: bash - run: | - - ACTION="$(jq -r '.action // ""' "$GITHUB_EVENT_PATH")" - PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" - PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" - PR_BODY_RAW="$(jq -r '.pull_request.body // ""' "$GITHUB_EVENT_PATH")" - - esc() { - python3 - <<'PY' - import html, sys - text = sys.stdin.read() - text = text.replace("\r\n", "\n").replace("\r", "\n") - if text.strip() == "": - text = "(empty)" - sys.stdout.write(html.escape(text, quote=False)) - PY - } - - truncate_body() { - python3 - <<'PY' - import sys - s = sys.stdin.read() - max_len = 2500 - if len(s) > max_len: - s = s[:max_len] + "\n…(truncated)…" - sys.stdout.write(s) - PY - } - - PR_TITLE="$(printf '%s' "$PR_TITLE_RAW" | esc)" - PR_URL_ESC="$(printf '%s' "$PR_URL" | esc)" - PR_BODY="$(printf '%s' "$PR_BODY_RAW" | esc | truncate_body)" - - cat > tg_pr.html <PR URL: $PR_URL_ESC - ${GITHUB_ACTOR} triggered PR event: $(printf '%s' "$ACTION" | esc) - Title: $PR_TITLE -
$PR_BODY
- EOF - - - name: Build Telegram message (PR Review Comment) - if: ${{ github.event_name == 'pull_request_review_comment' }} - shell: bash - run: | - - PR_URL="$(jq -r '.pull_request.html_url // ""' "$GITHUB_EVENT_PATH")" - PR_TITLE_RAW="$(jq -r '.pull_request.title // ""' "$GITHUB_EVENT_PATH")" - COMMENT_URL="$(jq -r '.comment.html_url // ""' "$GITHUB_EVENT_PATH")" - COMMENT_BODY_RAW="$(jq -r '.comment.body // ""' "$GITHUB_EVENT_PATH")" - - esc() { - python3 - <<'PY' - import html, sys - text = sys.stdin.read() - text = text.replace("\r\n", "\n").replace("\r", "\n") - if text.strip() == "": - text = "(empty)" - sys.stdout.write(html.escape(text, quote=False)) - PY - } - - truncate_body() { - python3 - <<'PY' - import sys - s = sys.stdin.read() - max_len = 2500 - if len(s) > max_len: - s = s[:max_len] + "\n…(truncated)…" - sys.stdout.write(s) - PY - } - - PR_TITLE="$(printf '%s' "$PR_TITLE_RAW" | esc)" - PR_URL_ESC="$(printf '%s' "$PR_URL" | esc)" - COMMENT_URL_ESC="$(printf '%s' "$COMMENT_URL" | esc)" - COMMENT_BODY="$(printf '%s' "$COMMENT_BODY_RAW" | esc | truncate_body)" - - cat > tg_pr_comment.html <Comment URL: $COMMENT_URL_ESC - PR URL: $PR_URL_ESC - PR: $PR_TITLE - ${GITHUB_ACTOR} commented: -
$COMMENT_BODY
- EOF - - # ---------------------------- - # Send (with fallback) - # ---------------------------- + { + echo "Issue URL: ${{ github.event.issue.html_url }}" + echo "${{ github.actor }} triggered issue event: ${{ github.event.action }}" + echo "Title: ${{ github.event.issue.title }}" + echo "
$ESCAPED_BODY
" + } >> tg_message.html - name: Send Telegram (Issue) if: ${{ github.event_name == 'issues' }} - id: tg_issue - continue-on-error: true uses: appleboy/telegram-action@v1.0.1 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} format: html disable_web_page_preview: true - message_file: tg_issue.html + message_file: tg_message.html - - name: Send Telegram Fallback (Issue) - if: ${{ github.event_name == 'issues' && steps.tg_issue.outcome == 'failure' }} - uses: appleboy/telegram-action@v1.0.1 - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - disable_web_page_preview: true - message: | - 🚨 Issue Notification 🚨 -
cannot parse message to telegram
+ - name: Build Telegram message (Issue Comment) + if: ${{ github.event_name == 'issue_comment' }} + shell: bash + env: + BODY: ${{ github.event.comment.body }} + run: | + ESCAPED_COMMENT=$(printf '%s' "$BODY" \ + | tr -d '\r' \ + | sed -e 's/&/\&/g' -e 's//\>/g') + + cat > tg_message.html <<'EOF' + šŸ“ Comment on Issue šŸ“ + EOF + + { + echo "Comment URL: ${{ github.event.comment.html_url }}" + echo "Issue URL: ${{ github.event.issue.html_url }}" + echo "${{ github.actor }} commented:" + echo "
$ESCAPED_COMMENT
" + } >> tg_message.html - name: Send Telegram (Issue Comment) if: ${{ github.event_name == 'issue_comment' }} - id: tg_issue_comment - continue-on-error: true uses: appleboy/telegram-action@v1.0.1 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} format: html disable_web_page_preview: true - message_file: tg_issue_comment.html + message_file: tg_message.html - - name: Send Telegram Fallback (Issue Comment) - if: ${{ github.event_name == 'issue_comment' && steps.tg_issue_comment.outcome == 'failure' }} - uses: appleboy/telegram-action@v1.0.1 - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - disable_web_page_preview: true - message: | - šŸ“ Comment on Issue šŸ“ -
cannot parse message to telegram
+ - name: Build Telegram message (Pull Request) + if: ${{ github.event_name == 'pull_request' }} + shell: bash + env: + BODY: ${{ github.event.pull_request.body }} + run: | + ESCAPED_PR_BODY=$(printf '%s' "$BODY" \ + | tr -d '\r' \ + | sed -e 's/&/\&/g' -e 's//\>/g') + + cat > tg_message.html <<'EOF' + šŸš€ Pull Request Notification šŸš€ + EOF + + { + echo "PR URL: ${{ github.event.pull_request.html_url }}" + echo "${{ github.actor }} triggered PR event: ${{ github.event.action }}" + echo "Title: ${{ github.event.pull_request.title }}" + echo "
$ESCAPED_PR_BODY
" + } >> tg_message.html - name: Send Telegram (Pull Request) if: ${{ github.event_name == 'pull_request' }} - id: tg_pr - continue-on-error: true uses: appleboy/telegram-action@v1.0.1 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} format: html disable_web_page_preview: true - message_file: tg_pr.html + message_file: tg_message.html - - name: Send Telegram Fallback (Pull Request) - if: ${{ github.event_name == 'pull_request' && steps.tg_pr.outcome == 'failure' }} - uses: appleboy/telegram-action@v1.0.1 - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - disable_web_page_preview: true - message: | - šŸš€ Pull Request Notification šŸš€ -
cannot parse message to telegram
- - - name: Send Telegram (PR Review Comment) + - name: Build Telegram message (PR Comment) if: ${{ github.event_name == 'pull_request_review_comment' }} - id: tg_pr_comment - continue-on-error: true - uses: appleboy/telegram-action@v1.0.1 - with: - to: ${{ secrets.TELEGRAM_TO }} - token: ${{ secrets.TELEGRAM_TOKEN }} - format: html - disable_web_page_preview: true - message_file: tg_pr_comment.html + shell: bash + env: + BODY: ${{ github.event.comment.body }} + run: | + ESCAPED_COMMENT=$(printf '%s' "$BODY" \ + | tr -d '\r' \ + | sed -e 's/&/\&/g' -e 's//\>/g') - - name: Send Telegram Fallback (PR Review Comment) - if: ${{ github.event_name == 'pull_request_review_comment' && steps.tg_pr_comment.outcome == 'failure' }} + cat > tg_message.html <<'EOF' + šŸ’¬ Comment on Pull Request šŸ’¬ + EOF + + { + echo "Comment URL: ${{ github.event.comment.html_url }}" + echo "PR URL: ${{ github.event.pull_request.html_url }}" + echo "${{ github.actor }} commented:" + echo "
$ESCAPED_COMMENT
" + } >> tg_message.html + + - name: Send Telegram (PR Comment) + if: ${{ github.event_name == 'pull_request_review_comment' }} uses: appleboy/telegram-action@v1.0.1 with: to: ${{ secrets.TELEGRAM_TO }} token: ${{ secrets.TELEGRAM_TOKEN }} format: html disable_web_page_preview: true - message: | - šŸ’¬ Comment on Pull Request šŸ’¬ -
cannot parse message to telegram
+ message_file: tg_message.html From 87f74e02398934148dd53d9ff52001a9c335ffd3 Mon Sep 17 00:00:00 2001 From: Heistergand Date: Thu, 19 Feb 2026 16:46:34 +0100 Subject: [PATCH 5/5] Update telegram-notifications2.yml --- .github/workflows/telegram-notifications2.yml | 104 +++++++++++++++--- 1 file changed, 87 insertions(+), 17 deletions(-) diff --git a/.github/workflows/telegram-notifications2.yml b/.github/workflows/telegram-notifications2.yml index 659270b..72bee21 100644 --- a/.github/workflows/telegram-notifications2.yml +++ b/.github/workflows/telegram-notifications2.yml @@ -1,4 +1,4 @@ -name: Telegram Notifications +name: Telegram Notifications v2 on: issues: @@ -19,19 +19,39 @@ jobs: shell: bash env: BODY: ${{ github.event.issue.body }} + ISSUE_URL: ${{ github.event.issue.html_url }} + ACTOR: ${{ github.actor }} + ACTION: ${{ github.event.action }} + TITLE: ${{ github.event.issue.title }} run: | ESCAPED_BODY=$(printf '%s' "$BODY" \ | tr -d '\r' \ - | sed -e 's/&/\&/g' -e 's//\>/g') + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ISSUE_URL=$(printf '%s' "$ISSUE_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTION=$(printf '%s' "$ACTION" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_TITLE=$(printf '%s' "$TITLE" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') cat > tg_message.html <<'EOF' 🚨 Issue Notification 🚨 EOF { - echo "Issue URL: ${{ github.event.issue.html_url }}" - echo "${{ github.actor }} triggered issue event: ${{ github.event.action }}" - echo "Title: ${{ github.event.issue.title }}" + echo "Issue URL: $ESCAPED_ISSUE_URL" + echo "$ESCAPED_ACTOR triggered issue event: $ESCAPED_ACTION" + echo "Title: $ESCAPED_TITLE" echo "
$ESCAPED_BODY
" } >> tg_message.html @@ -50,19 +70,34 @@ jobs: shell: bash env: BODY: ${{ github.event.comment.body }} + COMMENT_URL: ${{ github.event.comment.html_url }} + ISSUE_URL: ${{ github.event.issue.html_url }} + ACTOR: ${{ github.actor }} run: | ESCAPED_COMMENT=$(printf '%s' "$BODY" \ | tr -d '\r' \ - | sed -e 's/&/\&/g' -e 's//\>/g') + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_COMMENT_URL=$(printf '%s' "$COMMENT_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ISSUE_URL=$(printf '%s' "$ISSUE_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') cat > tg_message.html <<'EOF' šŸ“ Comment on Issue šŸ“ EOF { - echo "Comment URL: ${{ github.event.comment.html_url }}" - echo "Issue URL: ${{ github.event.issue.html_url }}" - echo "${{ github.actor }} commented:" + echo "Comment URL: $ESCAPED_COMMENT_URL" + echo "Issue URL: $ESCAPED_ISSUE_URL" + echo "$ESCAPED_ACTOR commented:" echo "
$ESCAPED_COMMENT
" } >> tg_message.html @@ -81,19 +116,39 @@ jobs: shell: bash env: BODY: ${{ github.event.pull_request.body }} + PR_URL: ${{ github.event.pull_request.html_url }} + ACTOR: ${{ github.actor }} + ACTION: ${{ github.event.action }} + TITLE: ${{ github.event.pull_request.title }} run: | ESCAPED_PR_BODY=$(printf '%s' "$BODY" \ | tr -d '\r' \ - | sed -e 's/&/\&/g' -e 's//\>/g') + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_PR_URL=$(printf '%s' "$PR_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTION=$(printf '%s' "$ACTION" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_TITLE=$(printf '%s' "$TITLE" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') cat > tg_message.html <<'EOF' šŸš€ Pull Request Notification šŸš€ EOF { - echo "PR URL: ${{ github.event.pull_request.html_url }}" - echo "${{ github.actor }} triggered PR event: ${{ github.event.action }}" - echo "Title: ${{ github.event.pull_request.title }}" + echo "PR URL: $ESCAPED_PR_URL" + echo "$ESCAPED_ACTOR triggered PR event: $ESCAPED_ACTION" + echo "Title: $ESCAPED_TITLE" echo "
$ESCAPED_PR_BODY
" } >> tg_message.html @@ -112,19 +167,34 @@ jobs: shell: bash env: BODY: ${{ github.event.comment.body }} + COMMENT_URL: ${{ github.event.comment.html_url }} + PR_URL: ${{ github.event.pull_request.html_url }} + ACTOR: ${{ github.actor }} run: | ESCAPED_COMMENT=$(printf '%s' "$BODY" \ | tr -d '\r' \ - | sed -e 's/&/\&/g' -e 's//\>/g') + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_COMMENT_URL=$(printf '%s' "$COMMENT_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_PR_URL=$(printf '%s' "$PR_URL" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') + + ESCAPED_ACTOR=$(printf '%s' "$ACTOR" \ + | tr -d '\r' \ + | sed -e 's/&/\&amp;/g' -e 's//\&gt;/g') cat > tg_message.html <<'EOF' šŸ’¬ Comment on Pull Request šŸ’¬ EOF { - echo "Comment URL: ${{ github.event.comment.html_url }}" - echo "PR URL: ${{ github.event.pull_request.html_url }}" - echo "${{ github.actor }} commented:" + echo "Comment URL: $ESCAPED_COMMENT_URL" + echo "PR URL: $ESCAPED_PR_URL" + echo "$ESCAPED_ACTOR commented:" echo "
$ESCAPED_COMMENT
" } >> tg_message.html