mirror of
https://github.com/unraid/webgui.git
synced 2026-04-23 18:48:49 -05:00
backslash interpretations, ensure valid chat id
This commit is contained in:
@@ -240,17 +240,17 @@
|
||||
$STORED_TOKEN=$(cat /boot/config/telegram/token) || "";
|
||||
if [[ ! -f /boot/config/telegram/token || "$STORED_TOKEN" != "$BOT_TOKEN" ]]; then
|
||||
mkdir -p /boot/config/telegram;
|
||||
echo -e "$BOT_TOKEN" > /boot/config/telegram/token;
|
||||
echo $BOT_TOKEN > /boot/config/telegram/token;
|
||||
fi
|
||||
|
||||
if [[ ! -f /boot/config/telegram/chatid || "$STORED_TOKEN" != "$BOT_TOKEN" ]]; then
|
||||
mkdir -p /boot/config/telegram;
|
||||
curl https://api.telegram.org/bot$BOT_TOKEN/getUpdates | jq ".result | last .message .chat .id" > /boot/config/telegram/chatid;
|
||||
LASTCHATID=$(curl https://api.telegram.org/bot$BOT_TOKEN/getUpdates | jq ".result | last .message .chat .id");
|
||||
[[ $LASTCHATID =~ ^[0-9]+$ ]] && echo $LASTCHATID > /boot/config/telegram/chatid;
|
||||
fi
|
||||
|
||||
CHATID=$(cat /boot/config/telegram/chatid);
|
||||
MESSAGE=$(echo -e "$(hostname): $TITLE
|
||||
$MESSAGE");
|
||||
MESSAGE=$(echo -e "$(hostname): $TITLE\n$MESSAGE");
|
||||
curl -G -v "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" --data-urlencode "chat_id=$CHATID" --data-urlencode "text=$MESSAGE" 2>&1;
|
||||
]]>
|
||||
</Script>
|
||||
|
||||
Reference in New Issue
Block a user