GithubHelp home page GithubHelp logo

pyincomingslack's Introduction

pyIncomingSlack

Description

  • This Python module post to Channel/Groups in Slack.
  • Use 'Incoming WebHooks' in Slack.
  • Do not require to make users post only.

Required module

  • requests
  • json

Installation

Get Webhook URL

  1. Access to https://my.slack.com/services/new/incoming-webhook
  2. Choose a channel into "Post to Channel" pulldown list what you want to post massage.
  3. After choose a channel, Click "Incoming WebHooks Integration".
  4. You Copy URL into "Webhook URL". EX. https://hooks.slack.com/services/xxxxxxxxx/xxxxxxxxxx/xxxxxxxxxxxxxxxxx

Install module

pip install pyIncomingSlack

Usage

Import module

>>> import pyIncomingSlack

Preliminary preparation

pyIncomingSlack.pyIncomingSlack()

Parameter

  • Required
    • token_url
    • user_name
  • Optional
    • icon

Ex

>>> 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="http://hogehoge/hoge.png")

Post message

.send()

Parameter

  • Required
    • message
  • Optional
    • title
    • color (require title parameter)

Ex

>>> 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')

Shell usage

$ 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
                        "http://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

pyincomingslack's People

Contributors

t-ichii avatar

Stargazers

Nicholas Hatch avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.