Coder Social home page Coder Social logo

pyslack's Introduction

pyslack

ghit.me

A Python wrapper for Slack's API

https://api.slack.com

(Formerly) 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

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyslack's Issues

InsecurePlatformWarning when running test code

Installed the package on my mac and it runs fine, OS X 10.10, running python 2.7 inside a virtualenv (just to be clear what I'm running). Getting InsecurePlatformWarning errors thrown when running the test code. It this a recent change to the slack API or something fixable?

/Users/yaleman/Sync/Projects/slackbot/venv/lib/python2.7/site-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
InsecurePlatformWarning
/Users/yaleman/Sync/Projects/slackbot/venv/lib/python2.7/site-packages/requests/packages/urllib3/connectionpool.py:768: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.org/en/latest/security.html
InsecureRequestWarning)

pyslack wont install if you dont have `requests` already installed

Looks like you import from init.py in setup.py so it tries to import requests as wel just to get the version.

EDIT: replaced my fork with yours

$ pip install https://github.com/loisaidasam/pyslack/archive/master.zip
Downloading/unpacking https://github.com/loisaidasam/pyslack/archive/master.zip
Downloading master.zip (unknown size): 2.5kB downloaded
Storing download in cache at /home/vagrant/.pipdownloadcache/https%3A%2F%2Fgithub.com%2Fsherzberg%2Fpyslack%2Farchive%2Fmaster.zip
Running setup.py (path:/tmp/pip-5GVDCw-build/setup.py) egg_info for package from https://github.com/loisaidasam/pyslack/archive/master.zip
Traceback (most recent call last):
File "", line 17, in
File "/tmp/pip-5GVDCw-build/setup.py", line 4, in
from pyslack import version
File "pyslack/init.py", line 4, in
import requests
ImportError: No module named requests
Complete output from command python setup.py egg_info:
Traceback (most recent call last):

File "", line 17, in

File "/tmp/pip-5GVDCw-build/setup.py", line 4, in

from pyslack import __version__

File "pyslack/init.py", line 4, in

import requests

ImportError: No module named requests


Cleaning up...
Command python setup.py egg_info failed with error code 1 in /tmp/pip-5GVDCw-build
Storing debug log for failure in /home/vagrant/.pip/pip.log

[Feature Request] upload file to room

This is an awesome module -- thanks!

I don't see a way of uploading a file to a chat room (unless I'm missing something). If this feature doesn't exist, I'd love to add it.

Pypi

I'm using pyslack in production (BTW great job, congrats ๐Ÿ‘ ) and I think the best way to version control is pypi.

Could you upload pyslack to pypi?

username does not use appropriate username tied to token

I setup a bot integration and a token and used it with pyslack in my python code. It is appropriately sending out the error messages to my channel, however, my bot is not using the icon that I associated with in its integration.

After further testing I have found out that I can arbitrarily set the username to anything, and it does not use the username that is associated with the token I created. This does not seem safe or correct. Shouldn't it only be using the associated username/info that is tied to a given token?

Make pyslack more resilient to slack failures

Slack is having an outage today where among other things they aren't properly responding to webhooks. This is causing pyslack to throw an exception in the JSON parser and bring down our whole application.

Is there a way to make the library catch these types of issues internally and fail silently if requested? The alternative is to wrap every logging call in a try/except block

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.