File tree Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Expand file tree Collapse file tree 1 file changed +19
-6
lines changed Original file line number Diff line number Diff line change 9
9
10
10
# Telegram API Token
11
11
# Find telegram bot named "@botfarther", type /mybots, select your bot and select "API Token" to see your current token
12
- TOKEN=${NOTIFY_PARAMETER_1}
12
+ if [ -z ${NOTIFY_PARAMETER_1} ]; then
13
+ echo " No Telegram token ID provided. Exiting" >&2
14
+ exit 2
15
+ else
16
+ TOKEN=" ${NOTIFY_PARAMETER_1} "
17
+ fi
13
18
14
19
# Telegram Chat-ID or Group-ID
15
20
# Open "https://api.telegram.org/bot<YOUR_TOKEN>/getUpdates" inside your Browser and send a HELLO to your bot, refresh side
16
- CHAT_ID=${NOTIFY_PARAMETER_2}
21
+ if [ -z ${NOTIFY_PARAMETER_2} ]; then
22
+ echo " No Telegram Chat-ID or Group-ID provided. Exiting" >&2
23
+ exit 2
24
+ else
25
+ CHAT_ID=" ${NOTIFY_PARAMETER_2} "
26
+ fi
17
27
18
28
# Create a MESSAGE variable to send to your Telegram bot
19
29
MESSAGE=" ${NOTIFY_HOSTNAME} (${NOTIFY_HOSTALIAS} )%0A"
@@ -30,7 +40,10 @@ MESSAGE+="%0AIPv4: ${NOTIFY_HOST_ADDRESS_4} %0AIPv6: ${NOTIFY_HOST_ADDRESS_6}%0A
30
40
MESSAGE+=" ${NOTIFY_SHORTDATETIME} "
31
41
32
42
# Send message to Telegram bot
33
- curl -s -X POST " https://api.telegram.org/bot${TOKEN} /sendMessage" -d chat_id=" ${CHAT_ID} " -d text=" ${MESSAGE} " >> /dev/null
34
-
35
- # End of script
36
- exit 0
43
+ curl -S -X POST " https://api.telegram.org/bot${TOKEN} /sendMessage" -d chat_id=" ${CHAT_ID} " -d text=" ${MESSAGE} "
44
+ if [ $? -ne 0 ]; then
45
+ echo " Not able to send Telegram message" >&2
46
+ exit 2
47
+ else
48
+ exit 0
49
+ fi
You can’t perform that action at this time.
0 commit comments