Skip to content

Instantly share code, notes, and snippets.

Created September 19, 2014 15:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
post a message to a slack channel
@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=
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%"
cd %~dp0
..\curl\curl -k -X POST --data-urlencode %data% %url%
goto done
echo Invalid usage
echo Usage: slack-message.bat message channel(include the leading #)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment