Skip to content

Commit b432a6f

Browse files
committed
fix(discord-notify): improve message formatting and structure for notifications
1 parent b80775d commit b432a6f

2 files changed

Lines changed: 24 additions & 11 deletions

File tree

-383 Bytes
Binary file not shown.

.github/scripts/discord-notify.sh

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ if [[ -z "${DISCORD_WEBHOOK_URL:-}" ]]; then
77
exit 0
88
fi
99

10-
# Emojis custom (servidor Discord) e cargo a mencionar (spoiler)
10+
# Emojis custom do servidor — formato <:nome:id> (obrigatório no Discord)
1111
EMOJI_NOTEPAD="<:notepad:1469775431237501083>"
1212
EMOJI_COFFEE="<:coffeepikachu:1469777951867273216>"
1313
ROLE_ID="1465931358609215520"
@@ -32,36 +32,49 @@ post_discord() {
3232
}
3333

3434
# —— Sucesso com lições novas: mensagem para alunos + ping ao cargo ——
35+
# Título com notepad em `content`; detalhes + coffeepikachu no embed (IDs acima).
3536
if [[ "$STATUS" == "success" && "$PUBLISHED" -gt 0 ]]; then
36-
MESSAGE="${EMOJI_NOTEPAD} **Conteúdo novo acabou de cair no ISS**"
37+
HEADLINE="${EMOJI_NOTEPAD} **Conteúdo novo acabou de cair no ISS**"
38+
EMBED_BODY=""
3739

3840
if [[ -n "$LAST_DISCIPLINE_TITLE" ]]; then
39-
MESSAGE="${MESSAGE}
40-
41-
${LAST_DISCIPLINE_TITLE}"
41+
EMBED_BODY="${LAST_DISCIPLINE_TITLE}"
4242
fi
4343

4444
if [[ -n "$LAST_LESSON_TITLE" ]]; then
45-
MESSAGE="${MESSAGE}
45+
if [[ -n "$EMBED_BODY" ]]; then
46+
EMBED_BODY="${EMBED_BODY}
4647
» ${LAST_LESSON_TITLE}"
48+
else
49+
EMBED_BODY="» ${LAST_LESSON_TITLE}"
50+
fi
4751
fi
4852

4953
if [[ -n "$LAST_LESSON_DESCRIPTION" ]]; then
50-
MESSAGE="${MESSAGE}
54+
if [[ -n "$EMBED_BODY" ]]; then
55+
EMBED_BODY="${EMBED_BODY}
5156
5257
${LAST_LESSON_DESCRIPTION}"
58+
else
59+
EMBED_BODY="${LAST_LESSON_DESCRIPTION}"
60+
fi
5361
fi
5462

55-
MESSAGE="${MESSAGE}
63+
if [[ -n "$EMBED_BODY" ]]; then
64+
EMBED_BODY="${EMBED_BODY}
5665
57-
🔗 ${ISS_URL}
66+
"
67+
fi
68+
EMBED_BODY="${EMBED_BODY}🔗 ${ISS_URL}
5869
5970
${EMOJI_COFFEE} Tudo organizadinho pra consultar depois sem sofrer no AVA."
6071

6172
PAYLOAD="$(jq -n \
62-
--arg content "||<@&${ROLE_ID}>||" \
73+
--arg content "||<@&${ROLE_ID}>||
74+
75+
${HEADLINE}" \
6376
--arg role "$ROLE_ID" \
64-
--arg desc "$MESSAGE" \
77+
--arg desc "$EMBED_BODY" \
6578
'{
6679
content: $content,
6780
allowed_mentions: { parse: [], roles: [$role] },

0 commit comments

Comments
 (0)