Created
March 27, 2020 00:07
-
-
Save santaklouse/af2b200587ebd1e0f9f2a0a52439844f to your computer and use it in GitHub Desktop.
Send message to telegram bot
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/sh | |
| API_TOKEN='TG_API_TOKEN' | |
| CHAT_ID='CHAT_ID' | |
| if [ -z "$CHAT_ID" ]; then | |
| echo 'Please, define CHAT_ID first! See "chat":{"id":xxxxxxx string below:' | |
| /usr/bin/wget -qO - https://api.telegram.org/bot$API_TOKEN/getUpdates | |
| exit 1 | |
| fi | |
| MSG="<b>$(nvram get computer_name)</b>: $@" | |
| if [ -z $@ ]; then | |
| while read data; do | |
| MSG=$MSG''$data | |
| /usr/bin/wget -qs "https://api.telegram.org/bot$API_TOKEN/sendMessage?chat_id=$CHAT_ID&parse_mode=html&text=$MSG" 2>&1 | |
| if [ $? -eq 0 ]; then | |
| echo 'Message sent successfully.' | |
| else | |
| echo 'Error while sending message!' | |
| exit 1 | |
| fi; | |
| exit 0; | |
| done | |
| fi; | |
| /usr/bin/wget -qs "https://api.telegram.org/bot$API_TOKEN/sendMessage?chat_id=$CHAT_ID&parse_mode=html&text=$MSG" 2>&1 | |
| if [ $? -eq 0 ]; then | |
| echo 'Message sent successfully.' | |
| else | |
| echo 'Error while sending message!' | |
| exit 1 | |
| fi |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Example: Store in web and send link to telegram
grep -Hir "Message sent" / | pastebin | tg_say