diff --git a/action.yml b/action.yml
index 316a7bf..fdf17df 100644
--- a/action.yml
+++ b/action.yml
@@ -11,6 +11,14 @@ inputs:
default: |
%23${{ github.run_number }} ${{ github.event.repository.name }}: ${{ github.workflow }}
\nrunner: ${{ env.GITEA_RUNNER_NAME }}
+ button_url:
+ description: "Button URL"
+ required: false
+ default: ''
+ button_title:
+ description: "Button title"
+ required: false
+ default: ''
message_id:
description: "Message ID"
required: false
@@ -74,7 +82,7 @@ runs:
CAPTION="$STATUS${{ inputs.caption }}"
echo $CAPTION
echo "$CAPTION${{ inputs.message }}"
- sendMessage "${{ inputs.bot_token }}" ${{ inputs.chat_id }} "$CAPTION${{ inputs.message }}"
+ sendMessage "${{ inputs.bot_token }}" ${{ inputs.chat_id }} "$CAPTION${{ inputs.message }}" "${{ inputs.button_title }}" "${{ inputs.button_url }}"
shell: bash
- name: Delete message
diff --git a/sendMessage b/sendMessage
index a7f55db..ec7c58a 100755
--- a/sendMessage
+++ b/sendMessage
@@ -1,16 +1,48 @@
#!/bin/bash
-response=$(curl -s -X POST "https://api.telegram.org/bot$1/sendMessage" \
- -d "chat_id=$2" \
- -d "parse_mode=HTML" \
- -d "link_preview_options={\"is_disabled\":true}" \
- -d "text=$(echo -e $3)")
+BOT_TOKEN="$1"
+CHAT_ID="$2"
+TEXT="$3"
+DOWNLOAD_TITLE="$4" # Необязательный
+DOWNLOAD_URL="$5" # Необязательный
-# if command -v jq >/dev/null 2>&1; then
- message_id=$(echo "$response" | jq '.result.message_id')
-# else
-# message_id=$(echo "$response" | grep -o '"message_id":[0-9]*' | sed 's/"message_id"://')
-# fi
+# Обработка текста с \n
+PARSED_TEXT=$(printf "%b" "$TEXT")
+
+# Базовый JSON без reply_markup
+JSON=$(jq -nc \
+ --arg chat_id "$CHAT_ID" \
+ --arg text "$PARSED_TEXT" \
+ '{
+ chat_id: $chat_id,
+ text: $text,
+ parse_mode: "HTML",
+ link_preview_options: { "is_disabled": true }
+ }')
+
+# Если передана ссылка — добавим кнопку
+if [[ -n "$DOWNLOAD_URL" ]]; then
+ JSON=$(echo "$JSON" | jq \
+ --arg text "$DOWNLOAD_TITLE" \
+ --arg url "$DOWNLOAD_URL" \
+ '. + {
+ reply_markup: {
+ inline_keyboard: [[
+ { text: $text, url: $url }
+ ]]
+ }
+ }')
+fi
+
+echo $JSON
+
+# Отправка запроса
+response=$(curl -s -X POST "https://api.telegram.org/bot${BOT_TOKEN}/sendMessage" \
+ -H "Content-Type: application/json" \
+ -d "$JSON")
+
+# Получаем message_id
+message_id=$(echo "$response" | jq '.result.message_id')
echo "Sent message with ID: $message_id"
-echo "OUTPUT_MESSAGE_ID=$message_id" >> $GITHUB_ENV
\ No newline at end of file
+echo "OUTPUT_MESSAGE_ID=$message_id" >> "$GITHUB_ENV"
\ No newline at end of file