Created
September 19, 2014 15:36
-
-
Save gsherman/b25256790ac42e70d2de to your computer and use it in GitHub Desktop.
post a message to a slack channel
This file contains 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
@echo off | |
set Count=0 | |
for %%a in (%*) do set /a Count+=1 | |
if %count% NEQ 2 goto usage | |
SET message=%1 | |
SET channel=%2 | |
SET token=mySecretToken | |
SET url=https://ourSlackAccount.slack.com/services/hooks/incoming-webhook?token=%token% | |
SET data=payload={"channel": "%channel%","text":%message%,"username": "focus-bot"} | |
REM escape all the double quotes | |
SET data=%data:"=\"% | |
REM wrap in double quotes | |
SET data="%data%" | |
c: | |
cd %~dp0 | |
..\curl\curl -k -X POST --data-urlencode %data% %url% | |
goto done | |
:usage | |
echo. | |
echo Invalid usage | |
echo Usage: slack-message.bat message channel(include the leading #) | |
echo. | |
:done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment