Skip to main content

A Python package that helps to interact with the Slack App

Project description

Slackybot

This Python package helps you with sending messages to Slack. It offers an object-oriented approach - every message or reply in a thread is an object, so they can be easily managed.

Getting started

Installation

python -m pip install slackybot

Add following token scopes to your Slack bot:
channels:join channels:read chat:write chat:write.customize chat:write.public

Simple usage

Import and initialize the slack object

from slackybot import Slack

slack = Slack(token='XXX')

As a best practice, it is better to pass the token using an environment variable (e.g. .env file)

To send a message you have to use the Slack object method. It takes two arguments: channel and text they are both strings.

slack.send_message(channel='channel-name', text='Sample text')

The above method returns the Message object.

To update a message you may use the Message method .update(). It takes one argument: text as a string.

message = slack.send_message(channel='', text='')
message.update(text='New text')

To send a reply in the message thread simply use .send_reply() method. It takes one argument: text as a string.

message = slack.send_message(channel='', text='')
message.send_reply(text='Reply message in the thread')

The above method returns the Reply object.

Both objects Message and Reply can be deleted by using .delete() method on them. Those objects can be listed using:

  • .get_messages() on the Slack object
  • .get_replies() on the Message object

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

slackybot-1.2.0.tar.gz (7.3 kB view hashes)

Uploaded Source

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