Skip to content

Instantly share code, notes, and snippets.

@xunzhou
Created July 16, 2018 01:48
Show Gist options
  • Save xunzhou/d3daafcf748f199c1e60b5b3ec8f292e to your computer and use it in GitHub Desktop.
Save xunzhou/d3daafcf748f199c1e60b5b3ec8f292e to your computer and use it in GitHub Desktop.
Send Message to Telegram Bot
#!/bin/bash
bot_key="<API Token from BotFather>"
# Need to send a message to your bot in order to see chat_id.
chat_id="<chat_id from https://api.telegram.org/bot<bot_key>/getUpdates>"
response=$(curl -s "https://api.telegram.org/bot$bot_key/sendMessage?chat_id=$chat_id&text=$@")
status=$(echo $response | cut -d ':' -f2 | cut -d ',' -f1)
echo "Sent: $status"
@xunzhou
Copy link
Author

xunzhou commented Jul 16, 2018

spaces in messages need to be quoted.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment