notification/templates/sendtelegram-login.sh

25 lines
672 B
Bash

#! /bin/sh
API_URL="$(grep "API_URL=" | cut -d= -f2)"
SILENCE="$(grep "SILENCE=" | cut -d= -f2)"
CHAT_ID="$(grep "CHAT_ID=" | cut -d= -f2)"
THRD_ID="$(grep "THRD_ID=" | cut -d= -f2)"
TXT_MSG="[Authorization] $(cat /etc/hostname):
$(w -h)"
(
if [ -z "${THRD_ID}" ]; then
curl -s -o /dev/null -X POST \
-d chat_id="${CHAT_ID}" \
-d text="${TXT_MSG}" \
-d disable_notification="${SILENCE}" \
"${API_URL}"
else
curl -s -o /dev/null -X POST \
-d chat_id="${CHAT_ID}" \
-d text="$TXT_MSG" \
-d disable_notification="${SILENCE}" \
-d message_thread_id="$THRD_ID" \
"${API_URL}"
fi
)