1234567891011121314151617181920212223242526272829303132 |
- #!/bin/env bash
- BOT_API_KEY=$(sh .bot.env)
- MY_REQUEST="https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=[MY_CHANNEL_NAME]&text=[MY_MESSAGE_TEXT]"
- CHANNEL_ID="-1001626848940"
- MY_MESSAGE=$@
- if [ -z $MY_MESSAGE ]; then
- MY_MESSAGE="waiting for VM available"
- fi
- echo $MY_MESSAGE
- MY_MESSAGE=$(echo $MY_MESSAGE | sed "s/\s/\%20/g" )
- for Line in $MY_MESSAGE; do
- MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[BOT_API_KEY\]/$BOT_API_KEY/" )
- MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[MY_CHANNEL_NAME\]/$CHANNEL_ID/" )
- MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[MY_MESSAGE_TEXT\]/$Line/" )
- # echo $Line
- curl $MY_REQUEST
- done
|