- This Python module post to Channel/Groups in Slack.
- Use 'Incoming WebHooks' in Slack.
- Do not require to make users post only.
- requests
- json
- Access to https://my.slack.com/services/new/incoming-webhook
- Choose a channel into "Post to Channel" pulldown list what you want to post massage.
- After choose a channel, Click "Incoming WebHooks Integration".
- You Copy URL into "Webhook URL".
EX.
https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxx
pip install pyIncomingSlack
>>> import pyIncomingSlack
pyIncomingSlack.pyIncomingSlack()
- Required
- token_url
- user_name
- Optional
- icon
>>> slack_instance = pyIncomingSlack.pyIncomingSlack(token_url = 'https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxx', user_name = 'python_bot')
you want to use emoji icon,
>>> slack_instance = pyIncomingSlack.pyIncomingSlack(token_url = 'https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxx', user_name = 'python_bot', icon=":ghost:")
you want to use image icon,
>>> slack_instance = pyIncomingSlack.pyIncomingSlack(token_url = 'https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxx', user_name = 'python_bot', icon="https://hogehoge/hoge.png")
.send()
- Required
- message
- Optional
- title
- color (require title parameter)
>>> slack_instance.send(message = 'send message')
You can choice color parameter 'good', 'warning', 'danger' or hex color code(ex:'#36a64f').
>>> slack_instance.send(message = 'send message', title = 'title param', color = 'good')
$ pyIncomingSlack -h
usage: pyIncomingSlack [-h] -t TOKEN_URL -u USER_NAME -m MESSAGE [-i ICON]
[-T TITLE] [-c COLOR]
This script send message for Slack.
optional arguments:
-h, --help show this help message and exit
-t TOKEN_URL, --token-url TOKEN_URL
You get Webhook URL from
https://my.slack.com/services/new/incoming-webhook
-u USER_NAME, --user-name USER_NAME
User name for writing message.
-m MESSAGE, --message MESSAGE
Send detail message body.
-i ICON, --icon ICON Use emoji, like ":ghost:". Use image file, like
"https://hogehoge/hoge.png"
-T TITLE, --title TITLE
Send detail message body.
-c COLOR, --color COLOR
color parameter "good", "warning", "danger" or hex
color code(ex:"#36a64f"). This parameter require to
add title parameter
$ pyIncomingSlack \
-t https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/ \
-u Python_ghost \
-m "test message" \
-i :ghost: \
-T "Title value" \
-c good