Skip to content

每日签到(tg通知) #314

每日签到(tg通知)

每日签到(tg通知) #314

name: 每日签到(tg通知)
on:
schedule:
- cron: '30 8 * * *'
workflow_dispatch:
jobs:
daily-checkin:
runs-on: ubuntu-latest
steps:
- name: 獲取信息
id: get-info
run: |
response=$(curl -s -X GET \
-H "Content-Type: application/json" \
-H "x-api-key: ${{ secrets.RAINYUN_API_KEY }}" \
https://api.v2.rainyun.com/user/)
name=$(echo $response | jq -r '.data.Name')
points=$(echo $response | jq -r '.data.Points')
icon_url=$(echo $response | jq -r '.data.IconUrl')
echo "::set-output name=name::$name"
echo "::set-output name=points::$points"
echo "::set-output name=icon_url::$icon_url"
- name: 发送用戶信息
run: |
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bot ${{ secrets.TELEGRAM_BOT_TOKEN }}" \
-d '{
"chat_id": ${{ secrets.TELEGRAM_CHAT_ID }},
"photo": "'"${{ steps.get-info.outputs.icon_url }}"'",
"caption": "尊敬的'"${{ steps.get-info.outputs.name }}"'大人,即将为您签到!当前剩余积分'"${{ steps.get-info.outputs.points }}"'!"
}' \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendPhoto"
- name: 发送签到请求
id: checkin
run: |
response=$(curl -s -X POST \
-H "Content-Type: application/json" \
-H "x-api-key: ${{ secrets.RAINYUN_API_KEY }}" \
-d '{"task_name": "每日签到"}' \
https://api.v2.rainyun.com/user/reward/tasks)
echo "::set-output name=response::$response"
- name: 发送签到结果
run: |
curl -s -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bot ${{ secrets.TELEGRAM_BOT_TOKEN }}" \
-d '{
"chat_id": ${{ secrets.TELEGRAM_CHAT_ID }},
"text": "每日签到已完成!\n签到结果: '"${{ steps.checkin.outputs.response }}"'"
}' \
"https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage"