transfer.sh 657 B

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/env bash
  2. BOT_API_KEY=$(sh .bot.env)
  3. MY_REQUEST="https://api.telegram.org/bot[BOT_API_KEY]/sendMessage?chat_id=[MY_CHANNEL_NAME]&text=[MY_MESSAGE_TEXT]"
  4. CHANNEL_ID="-1001626848940"
  5. MY_MESSAGE=$@
  6. if [ -z $MY_MESSAGE ]; then
  7. MY_MESSAGE="waiting for VM available"
  8. fi
  9. echo $MY_MESSAGE
  10. MY_MESSAGE=$(echo $MY_MESSAGE | sed "s/\s/\%20/g" )
  11. for Line in $MY_MESSAGE; do
  12. MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[BOT_API_KEY\]/$BOT_API_KEY/" )
  13. MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[MY_CHANNEL_NAME\]/$CHANNEL_ID/" )
  14. MY_REQUEST=$(echo $MY_REQUEST | sed "s/\[MY_MESSAGE_TEXT\]/$Line/" )
  15. # echo $Line
  16. curl $MY_REQUEST
  17. done