Skip to content

Instantly share code, notes, and snippets.

@faishal
Created July 18, 2024 03:24
Show Gist options
  • Save faishal/ecb9e6dfacd76efcb02b5fb7be0a8d11 to your computer and use it in GitHub Desktop.
Save faishal/ecb9e6dfacd76efcb02b5fb7be0a8d11 to your computer and use it in GitHub Desktop.
TTP / Nexus Appointent notification on telegram
TOKEN="XXXX" # Telegram both token
IDF="XXX" # DM / GROUP ID 1
IDS="XXX" # DM / GROUP ID 2
URL="https://api.telegram.org/bot$TOKEN/sendMessage"
LOCATION1=5020 # Blaine
LOCATION2=16764 # Blaine New
PREV1=""
PREV2=""
while sleep $((0 + $RANDOM % 10)); do
TEXT=$(curl "https://ttp.cbp.dhs.gov/schedulerapi/slot-availability?locationId=${LOCATION1}" --compressed -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-CA,en-US;q=0.7,en;q=0.3' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: none' -H 'Sec-Fetch-User: ?1' -H 'Priority: u=1' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers' | jq -r '.availableSlots')
echo $TEXT
if [ "$TEXT" != "[]" ]; then
if [[ ! -z "$TEXT" ]]; then
if [[ "$TEXT" != "$PREV1" ]]; then
curl -s -X POST $URL -d chat_id=$IDF -d text="$TEXT https://ttp.dhs.gov/"
curl -s -X POST $URL -d chat_id=$IDS -d text="$TEXT https://ttp.dhs.gov/"
PREV1="$TEXT"
fi
fi
fi
TEXT=$(curl "https://ttp.cbp.dhs.gov/schedulerapi/slot-availability?locationId=${LOCATION2}" --compressed -H 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:127.0) Gecko/20100101 Firefox/127.0' -H 'Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8' -H 'Accept-Language: en-CA,en-US;q=0.7,en;q=0.3' -H 'Accept-Encoding: gzip, deflate, br, zstd' -H 'DNT: 1' -H 'Sec-GPC: 1' -H 'Connection: keep-alive' -H 'Upgrade-Insecure-Requests: 1' -H 'Sec-Fetch-Dest: document' -H 'Sec-Fetch-Mode: navigate' -H 'Sec-Fetch-Site: none' -H 'Sec-Fetch-User: ?1' -H 'Priority: u=1' -H 'Pragma: no-cache' -H 'Cache-Control: no-cache' -H 'TE: trailers' | jq -r '.availableSlots')
echo $TEXT
if [ "$TEXT" != "[]" ]; then
if [[ ! -z "$TEXT" ]]; then
if [[ "$TEXT" != "$PREV2" ]]; then
curl -s -X POST $URL -d chat_id=$IDF -d text="$TEXT https://ttp.dhs.gov/"
curl -s -X POST $URL -d chat_id=$IDS -d text="$TEXT https://ttp.dhs.gov/"
PREV2="$TEXT"
fi
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment