#!/bin/bash
set -euo pipefail

# -- Constantes -- #
SERVER='https://openbokeron.uma.es'
TOKEN='TOKEN_AQUI'
CHATID='CHATID_AQUI'

if curl -sSf $SERVER > /dev/null; then
    echo "Server OK"
else
    # Server down
    curl -s -X POST \
     -H 'Content-Type: application/json' \
     -d "{\"chat_id\": \"$CHATID\", \"text\": \"$SERVER\", \"disable_notification\": false}" \
     https://api.telegram.org/bot$TOKEN/sendMessage > /dev/null
    exit 1
fi
