Last active
February 17, 2019 11:40
-
-
Save ypchen/b464cc9ed30e7d66a583d76b38e13809 to your computer and use it in GitHub Desktop.
Revisions
-
ypchen revised this gist
Feb 17, 2019 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -38,4 +38,4 @@ fi text="${MSG_PREFIX}${text}${MSG_APPENDIX}" curl --insecure -X POST -H 'Content-type: application/json' --data '{"text":"'"${text}"'"}' "${webhook_url}" -
ypchen created this gist
Feb 17, 2019 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,41 @@ #!/bin/bash # default if [ -z ${CURL+x} ]; then CURL="/usr/bin/curl" fi if [ -z ${ECHO+x} ]; then ECHO="/usr/bin/echo" fi if [ -z ${CUT+x} ]; then CUT="/usr/bin/cut" fi # webhook_url, MSG_PREFIX, & CURL, ECHO, CUT if necessary CONF="${HOME}/.Slack.conf" source ${CONF} if [ -z ${MSG_PREFIX+x} ]; then MSG_PREFIX="" fi if [ -z ${MSG_APPENDIX+x} ]; then MSG_APPENDIX="" fi if [ -z ${text+x} ]; then text="${1}" fi prefixMode=$(${ECHO} "${text}" | ${CUT} -c 1-4) if [ "${prefixMode}" == "YPM0" ]; then text=$(${ECHO} "${text}" | ${CUT} -c 5-) elif [ "${prefixMode}" == "YPM1" ]; then text=$(${ECHO} "${text}" | ${CUT} -c 5-) msg=$(eval ${ECHO} "${text}") text=$(${ECHO} -e "${msg}") fi text="${MSG_PREFIX}${text}${MSG_APPENDIX}" curl --insecure -X POST -H 'Content-type: application/json' --data '{"text":"${text}"}' "${webhook_url}"