server {
listen 80;
server_name my-telegram-proxy.server;
location / {
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass https://api.telegram.org/;
client_max_body_size 100M;
}
}
#!/bin/sh
API_TOKEN=''
CHAT_ID=''
if [ -z "$CHAT_ID" ]; then
echo 'Please, define CHAT_ID first! See "chat":{"id":xxxxxxx string below:'
/usr/bin/wget -qO - https://api.telegram.org/bot$API_TOKEN/getUpdates
exit 1
fi
MSG="<b>$(nvram get computer_name)</b>: $@"
/usr/bin/wget -qs "https://api.telegram.org/bot$API_TOKEN/sendMessage?chat_id=$CHAT_ID&parse_mode=html&text=$MSG" 2>&1
if [ $? -eq 0 ]; then
echo 'Message sent successfully.'
else
echo 'Error while sending message!'
exit 1
fi