Created
October 7, 2023 15:25
-
-
Save Jipok/cbc4c3cfb39ee6fc10cfdee2084c5965 to your computer and use it in GitHub Desktop.
Send messages to telegram via bash
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 | |
# 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