GithubHelp home page GithubHelp logo

pyslack's Introduction

pyslack

A Python wrapper for Slack's API

https://api.slack.com

Listed as an official python client on Slack's Community-built Integrations page

Installation

pip install pyslack-real

(some chump stole the pyslack name right out from under me!)

Usage

Post a message into your Slack integration's #play channel

>>> from pyslack import SlackClient
>>> client = SlackClient('YOUR-TOKEN-HERE')
>>> client.chat_post_message('#play', "testing, testing...", username='slackbot')
{u'ok': 1, u'timestamp': u'1392000237000006'}

Integrate a SlackHandler into your logging!

>>> import logging
>>> from pyslack import SlackHandler

>>> logger = logging.getLogger('test')
>>> logger.setLevel(logging.DEBUG)

>>> handler = SlackHandler('YOUR-TOKEN-HERE', '#channel_name', username='botname')
>>> handler.setLevel(logging.WARNING)
>>> formatter = logging.Formatter('%(asctime)s [%(levelname)s] %(name)s (%(process)d): %(message)s')
>>> handler.setFormatter(formatter)
>>> logger.addHandler(handler)

>>> logger.error("Oh noh!") # Will post the formatted message to channel #channel_name from user botname

Testing

Before running the test suite, you'll need to add the required libraries to your environment. These aren't included in the main requirements.txt because they are not needed for normal operation of pyslack.

pip install -r tests/requirements.txt

The tests can be run as follows:

$ python setup.py test

pyslack's People

Contributors

aquarion avatar gavinhodge avatar hery avatar loisaidasam avatar meunierd avatar sherzberg avatar steinnes 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.