Отправить сообщение GET PIPE
#
#!/bin/sh
TELEGRAM_TOKEN=''
message=$( cat )
sendTelegram() {
curl -s \
-X POST \
https://api.telegram.org/bot${TELEGRAM_TOKEN}/sendMessage \
-d parse_mode=html \
-d text="$message" \
-d chat_id=${TELEGRAM_CHAT_ID}
}
if [[ -z "$message" ]]; then
echo "Please pipe a message to me!"
else
sendTelegram
fi
Отправить сообщение POST ARG
#
#!/bin/sh
API_TOKEN=''
CHAT_ID=''
if [ -z "$CHAT_ID" ]; then
echo 'Please, define CHAT_ID first! See "chat":{"id":xxxxxxx string below:'
https_proxy=http://192.168.1.1:9144 curl -s https://api.telegram.org/bot$API_TOKEN/getUpdates > /dev/null
exit 1
fi
MSG="<b>$(nvram get computer_name)</b>: $@"
https_proxy=http://192.168.1.1:9144 curl -s "https://api.telegram.org/bot$API_TOKEN/sendMessage?chat_id=$CHAT_ID&parse_mode=html&text=$MSG" > /dev/null
if [ $? -eq 0 ]; then
echo 'Message sent successfully.'
else
echo 'Error while sending message!'
exit 1
fi