Created
July 14, 2025 07:46
-
-
Save tawfekov/15a5580557e5fccdbccb06900b2da48e to your computer and use it in GitHub Desktop.
Monitor domain status and send updates to telegram
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
DOMAIN="targetdomain.com" # e.g., yahoo.com | |
BOT_TOKEN="your telegram bot token" | |
CHAT_ID="your telegram chat id with the bot" | |
LAST_STATUS_FILE="/tmp/domain_status_$DOMAIN.txt" | |
# Get WHOIS data | |
WHOIS_DATA=$(whois $DOMAIN 2>/dev/null) | |
# Extract first Domain Status | |
FIRST_STATUS=$(echo "$WHOIS_DATA" | grep -m 1 -i "^Domain Status:" | awk '{print $3}') | |
# Extract Last update of WHOIS database | |
LAST_UPDATE=$(echo "$WHOIS_DATA" | grep -i "Last update of WHOIS database" | sed 's/.*: //') | |
if [ ! -f "$LAST_STATUS_FILE" ]; then | |
echo "$FIRST_STATUS" > "$LAST_STATUS_FILE" | |
MESSAGE="Initial check: | |
$DOMAIN | |
Status: $FIRST_STATUS | |
Last update: $LAST_UPDATE" | |
curl -s -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ | |
-d chat_id="$CHAT_ID" \ | |
-d text="$MESSAGE" | |
exit 0 | |
fi | |
LAST_STATUS=$(cat "$LAST_STATUS_FILE") | |
if [ "$FIRST_STATUS" != "$LAST_STATUS" ]; then | |
MESSAGE="🔔 Domain $DOMAIN status changed! | |
Previous: $LAST_STATUS | |
Current: $FIRST_STATUS | |
Last update: $LAST_UPDATE" | |
echo "$FIRST_STATUS" > "$LAST_STATUS_FILE" | |
else | |
MESSAGE="✅ Domain $DOMAIN status unchanged: $FIRST_STATUS | |
Last update: $LAST_UPDATE" | |
fi | |
curl -s -X POST "https://api.telegram.org/bot$BOT_TOKEN/sendMessage" \ | |
-d chat_id="$CHAT_ID" \ | |
-d text="$MESSAGE" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment