Skip to content

Instantly share code, notes, and snippets.

@coffebar
Created October 20, 2017 18:56
Show Gist options
  • Save coffebar/29a9570870f01806dc23dd20501d1719 to your computer and use it in GitHub Desktop.
Save coffebar/29a9570870f01806dc23dd20501d1719 to your computer and use it in GitHub Desktop.
Щоб не забути вчасно продовжити домен .bit в блокчейн мережі отримуємо повідомлення в Telegram
#!/bin/bash
# domain google.bit
DOMAIN="google"
DOMAINSPACE="bit"
expires=$(curl "https://peername.net/api/?name=$DOMAIN&namespace=$DOMAINSPACE" 2>&1 | grep expires_in | grep -oE '[0-9]+')
notify_via_telegram()
{
MESSAGE=$1
# your telegram ID
TELEGRAM_CHAT='10000000'
# your bot
BOT_ID='20000000'
BOT_KEY='AAAAABBBBCCCCDDDDEEEEFFFF'
curl -X POST --silent -d "chat_id=$TELEGRAM_CHAT&text=$MESSAGE" "https://api.telegram.org/bot$BOT_ID:$BOT_KEY/sendMessage"
}
echo $expires
if [[ $expires -lt 1000 ]]; then
notify_via_telegram "Domain $DOMAIN.$DOMAINSPACE expires soon: $expires blocks"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment