Skip to content

Instantly share code, notes, and snippets.

@Jipok
Created October 7, 2023 15:25
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 Jipok/cbc4c3cfb39ee6fc10cfdee2084c5965 to your computer and use it in GitHub Desktop.
Save Jipok/cbc4c3cfb39ee6fc10cfdee2084c5965 to your computer and use it in GitHub Desktop.
Send messages to telegram via bash
#!/bin/bash
# Example: echo "Hello" | send.sh
#
message=$( cat )
apiToken=123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11
chatId=354339153 # Reciever ID
send() {
curl -s \
-X POST \
https://api.telegram.org/bot$apiToken/sendMessage \
-d text="$message" \
-d chat_id=$chatId \
-d parse_mode="HTML"
}
if [[ ! -z "$message" ]]; then
send
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment