Skip to content

Instantly share code, notes, and snippets.

@vpnwall-services
Last active April 21, 2024 21:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vpnwall-services/934d4538f52f1ed4808f67bfd0d56cb5 to your computer and use it in GitHub Desktop.
Save vpnwall-services/934d4538f52f1ed4808f67bfd0d56cb5 to your computer and use it in GitHub Desktop.
[Telegram Bot 101] Telegram Bot 101 #bash #telegram #bot #101
  • Install telegram on desktop
  • Message @botfather and then /newbot (give name, and other things)
  • Create new channel and add the bot
  • Get channel ID
curl -L https://api.telegram.org/bot$TELEGRAM_BOT_TOKEN/getUpdates
  • Add to .bashrc
export telegram_bot_token='xxxxx'
export telegram_house_channel_id='xxxxx'
export telegram_channel_url="https://api.telegram.org/bot$telegram_bot_token/sendMessage"
function telegram_notification(){
        curl -s -X POST $telegram_channel_url -d chat_id=$telegram_house_channel_id -d text="$(echo -e "[`hostname --fqdn`]: $@")"
}
  • Send message (working)
telegram_notification 'FART'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment