Skip to main content

Simple class to store slack profile information

Project description

slackperson

https://travis-ci.org/rickh94/slackperson.svg?branch=master https://codecov.io/gh/rickh94/slackperson/branch/master/graph/badge.svg

A simple class (SlackPerson) for retrieving and storing information about a person in your slack channel from the slack api.

Installation

$ pip install slackperson

You will also need the slackclient package.

Usage

The SlackPerson class can be initialized with the from_userlist method that allows you to supply a username or userid and the output of the users.list method to get data about a user.

After initialization, an instance of SlackPerson will have these attributes:

  • username: the username supplied at instantiation (if username was supplied with preceeding ‘@’, it will be stripped off.)

  • userid: the internal id of the user (this is useful for tagging in api generated messages.

  • email: the user’s account email address in slack

  • fname: the user’s first name

  • lname: the user’s last name

  • team: the user’s team id

Import and use the SlackPerson class:

from slackperson import SlackPerson
from slackclient import SlackClient

sc = SlackClient(os.environ['SLACK_API_TOKEN'])
userlist = sc.api_call('users.list')
me = SlackPerson.from_userlist('myusername', userlist)

If myusername is a member of your channel (i.e. on the userlist), the object me will now have all of the SlackPerson attributes. If not, it will raise SlackDataError. It will also raise SlackDataError if the userlist is malformed in any way.

Tests

There is a test case for a successful creation of a SlackPerson object and for the cases where exceptions should be raised. They are unittests so they can be run with unittest discovery or pytest.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

slackperson-0.5.1.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

slackperson-0.5.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file slackperson-0.5.1.tar.gz.

File metadata

  • Download URL: slackperson-0.5.1.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.10 CPython/3.7.1 Linux/4.19.2-arch1-1-ARCH

File hashes

Hashes for slackperson-0.5.1.tar.gz
Algorithm Hash digest
SHA256 128ed39aeb96f15ed6befffb7d07d4dab26a8c6765aa8ea89ae4ee1af2d2d2c5
MD5 41bba1191d783476a0e78105f5d1ec1e
BLAKE2b-256 002fb5a5153faf8e23b23b67da6ff714fba2f4d62f5296b9d3c24ccf37c2cca4

See more details on using hashes here.

File details

Details for the file slackperson-0.5.1-py3-none-any.whl.

File metadata

  • Download URL: slackperson-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/0.12.10 CPython/3.7.1 Linux/4.19.2-arch1-1-ARCH

File hashes

Hashes for slackperson-0.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 410e1780f8599cca5c7370e70a988bdab0c1c2734ad3f141f86f3a121ef696c2
MD5 860f9c7d890eb2b1269beccabe55d13d
BLAKE2b-256 591c7227c7dbdb9e84ed56339098446e12dd3965599a618b5e8294aa5c30216a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page