-
-
Notifications
You must be signed in to change notification settings - Fork 61
33 lines (26 loc) · 1.19 KB
/
dailyAdvice.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
name: Daily Advice
on:
schedule:
- cron: '0 17 * * *' # Runs every day at 17:00
workflow_dispatch:
jobs:
send_advice:
runs-on: ubuntu-latest
steps:
- name: Send daily advice
env:
DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }}
run: |
# Download JSON data
advices_json_url="https://raw.githubusercontent.com/DraftBot-A-Discord-Adventure/DraftBot/master/resources/text/advices.json"
advices_json=$(curl -s "$advices_json_url")
# Extract advice strings
advices_list=$(echo "$advices_json" | jq -r '.translations.fr.advices[]')
# Get a random advice
random_advice=$(echo "$advices_list" | shuf -n 1)
# Replace {command:...} with /...
random_advice=$(echo "$random_advice" | sed -E 's/\{command:([^}]+)\}/\/\1/g')
# Send advice to Discord webhook
content=":bulb: **Astuce du jour** :\n\n$random_advice\n\n<@&1136367073317113917>"
payload="{\"content\": \"$content\"}"
curl -s -X POST -H "Content-Type: application/json" -d "$payload" $DISCORD_WEBHOOK_URL