Skip to content
Open
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
127 changes: 38 additions & 89 deletions .github/workflows/telegram-send-message.yml
Original file line number Diff line number Diff line change
@@ -1,109 +1,58 @@
name: Telegram Send Message All Groups
name: Telegram Broadcast Custom Message
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This workflow now has the same name: as .github/workflows/telegram-broadcast.yml (“Telegram Broadcast Custom Message”). In the GitHub Actions UI this makes it hard to distinguish which workflow ran. Consider giving each workflow a distinct name (e.g., one for the dispatcher UI entrypoint vs the reusable sender).

Suggested change
name: Telegram Broadcast Custom Message
name: Telegram Send Custom Message

Copilot uses AI. Check for mistakes.

on:
workflow_call:
workflow_dispatch:
inputs:
message:
description: "Message to send to all Telegram groups"
description: 'The message to send to Telegram'
required: true
type: string
Comment on lines 3 to 9
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

This workflow was converted from a reusable workflow_call to workflow_dispatch and its inputs (parse_mode, test_mode) were removed. However, .github/workflows/telegram-broadcast.yml still calls this file via uses: ./.github/workflows/telegram-send-message.yml and passes parse_mode/test_mode, which requires this workflow to expose on: workflow_call with matching inputs. As-is, that caller workflow will fail to load/run. Consider restoring workflow_call (and inputs), or updating/removing the caller workflow accordingly.

Copilot uses AI. Check for mistakes.
parse_mode:
description: "Parse mode for Telegram message (HTML or Markdown)"
required: false
type: string
default: "HTML"
test_mode:
description: "If true, only send to testing group"
required: false
type: boolean
default: false

jobs:
send-message:
broadcast:
name: Broadcast Message
runs-on: ubuntu-latest

steps:
- name: Send message to Telegram groups
- name: Send Telegram Message
env:
MESSAGE_CONTENT: ${{ inputs.message }}
# This pulls the token and chat IDs from your GitHub Secrets
TELEGRAM_BOT_TOKEN: ${{ secrets.TELEGRAM_BOT_TOKEN }}
# Keeping multiple IDs if you have a list, otherwise it will just use the main one
TELEGRAM_CHAT_IDS: ${{ secrets.TELEGRAM_CHAT_IDS }}
MESSAGE: ${{ github.event.inputs.message }}
Comment on lines +19 to +23
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

There’s no guard for missing/empty TELEGRAM_BOT_TOKEN or TELEGRAM_CHAT_IDS. If either secret is unset/empty, the script may attempt requests with an invalid token or an empty chat id, making failures harder to diagnose. Consider adding an explicit early check that both are set and non-empty, and fail with a clear message if not.

Copilot uses AI. Check for mistakes.
PARSE_MODE: "Markdown"
Comment on lines +19 to +24
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

MESSAGE is sourced from ${{ github.event.inputs.message }}, which works for workflow_dispatch but will not work if this workflow is invoked as a reusable workflow (workflow_call). Using ${{ inputs.message }} is compatible with both patterns and avoids tying the implementation to the event payload shape.

Copilot uses AI. Check for mistakes.
run: |
# Pocket Network Bot Testing Group
CHAT_1="-1002895286734"
# BitGet <> Pocket Network (POKT)
CHAT_2="-4954094158"
# ByBit <> POKT
CHAT_3="-1002730340404"
# CoinEx <> POKT
CHAT_4="-1001946726820"
# Mr. Yang <> Grove / POKT
CHAT_5="-1002038833795"
# MEXC <> POKT
CHAT_6="-1002815210935"
# OKX <> Pocket Network
CHAT_7="-1001901668586"
# OrangeX <> Grove (POKT)
CHAT_8="-1002030782436"
# POKT & Gate.io
CHAT_9="-1001717732565"
# POKT Network | AscendEX
CHAT_10="-4565872373"
# Uphold <> Grove (POKT)
CHAT_11="-1002227693360"
# Pokt <> Kraken {EF introduction}
CHAT_12="-1002405763552"
# Bitrue & Pocket Network
CHAT_13="-618542738"
# HTX <> POKT
CHAT_14="-1002898513049"
# POKT <> Upbit
CHAT_15="-1002653157934"
# KuCoin <> POKT
CHAT_16="-775612675"
# Korbit <> POKT
CHAT_17="-1002811115444"
# The Poktopus Den
CHAT_18="-1001461397826"

# Get the message and parse mode from the workflow inputs
MESSAGE="$MESSAGE_CONTENT"
PARSE_MODE="${{ inputs.parse_mode }}"

# Function to send message to a chat
send_message() {
local chat_id="$1"
local chat_name="$2"
echo "Sending to $chat_id ($chat_name)"
curl -s -X POST https://api.telegram.org/bot7267336172:AAEYaEeY0i7DfbL7SsRjPf09N67mvLo8WC4/sendMessage \
echo "Sending message to Chat ID: $chat_id"

# Use the variable instead of the hardcoded token
RESPONSE=$(curl -s -X POST "https://api.telegram.org/bot${TELEGRAM_BOT_TOKEN}/sendMessage" \
-d chat_id="$chat_id" \
-d parse_mode="$PARSE_MODE" \
--data-urlencode text="$MESSAGE"
echo
--data-urlencode text="$MESSAGE")

# Check if the Telegram API returned an error
if echo "$RESPONSE" | grep -q '"ok":false'; then
echo "Error sending to $chat_id: $RESPONSE"
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

On failure this logs the full Telegram API response ($RESPONSE). Telegram responses can include the message text and chat details, which may be sensitive in GitHub Actions logs. Consider logging only the error description/code (or a redacted subset) instead of the entire response body.

Suggested change
echo "Error sending to $chat_id: $RESPONSE"
error_code=$(echo "$RESPONSE" | sed -n 's/.*"error_code":\([0-9]*\).*/\1/p')
description=$(echo "$RESPONSE" | sed -n 's/.*"description":"\([^"]*\)".*/\1/p')
echo "Error sending to $chat_id: code=${error_code:-unknown}, description=${description:-unavailable}"

Copilot uses AI. Check for mistakes.
return 1
else
echo "Success: Message sent to $chat_id"
Comment on lines +36 to +42
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

The error detection treats any response that does not contain '"ok":false' as success. If curl returns a non-JSON body (proxy error/HTML), an empty response, or a JSON error formatted differently, this can be reported as success. Consider checking the HTTP status/curl exit code and positively validating success (e.g., parse JSON and require ok == true).

Suggested change
# Check if the Telegram API returned an error
if echo "$RESPONSE" | grep -q '"ok":false'; then
echo "Error sending to $chat_id: $RESPONSE"
return 1
else
echo "Success: Message sent to $chat_id"
CURL_EXIT_CODE=$?
# First, check if curl itself failed
if [ "$CURL_EXIT_CODE" -ne 0 ]; then
echo "Error sending to $chat_id: curl exited with code $CURL_EXIT_CODE"
return 1
fi
# Then, positively validate that the Telegram API returned ok == true
if echo "$RESPONSE" | jq -e '.ok == true' > /dev/null 2>&1; then
echo "Success: Message sent to $chat_id"
else
echo "Error sending to $chat_id: $RESPONSE"
return 1

Copilot uses AI. Check for mistakes.
fi
}

# Check if test mode is enabled
TEST_MODE="${{ inputs.test_mode }}"

if [ "$TEST_MODE" = "true" ]; then
# Only send to testing group
echo "TEST MODE: Sending only to testing group"
send_message "$CHAT_1" "Pocket Network Bot Testing Group"
else
# Send to all chats
send_message "$CHAT_1" "Pocket Network Bot Testing Group"
send_message "$CHAT_2" "BitGet <> Pocket Network (POKT)"
send_message "$CHAT_3" "ByBit <> POKT"
send_message "$CHAT_4" "CoinEx <> POKT"
send_message "$CHAT_5" "Mr. Yang <> Grove / POKT"
send_message "$CHAT_6" "MEXC <> POKT"
send_message "$CHAT_7" "OKX <> Pocket Network"
send_message "$CHAT_8" "OrangeX <> Grove (POKT)"
send_message "$CHAT_9" "POKT & Gate.io"
send_message "$CHAT_10" "POKT Network | AscendEX"
send_message "$CHAT_11" "Uphold <> Grove (POKT)"
send_message "$CHAT_12" "Pokt <> Kraken {EF introduction}"
send_message "$CHAT_13" "Bitrue & Pocket Network"
send_message "$CHAT_14" "HTX <> POKT"
send_message "$CHAT_15" "POKT <> Upbit"
send_message "$CHAT_16" "KuCoin <> POKT"
send_message "$CHAT_17" "Korbit <> POKT"
send_message "$CHAT_18" "The Poktopus Den"
# Handle multiple chat IDs if they are comma-separated in your secret
IFS=',' read -ra ADDR <<< "$TELEGRAM_CHAT_IDS"
FAILED=0
for id in "${ADDR[@]}"; do
# Trim whitespace
id=$(echo $id | xargs)
Copy link

Copilot AI Feb 6, 2026

Choose a reason for hiding this comment

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

id=$(echo $id | xargs) should quote $id to avoid word-splitting/globbing surprises. Using a quoted expansion here makes the trimming robust even if the secret contains unexpected whitespace or characters.

Suggested change
id=$(echo $id | xargs)
id=$(echo "$id" | xargs)

Copilot uses AI. Check for mistakes.
send_message "$id" || FAILED=1
done

if [ $FAILED -ne 0 ]; then
echo "One or more messages failed to send."
exit 1
fi
Loading