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

Uploaded Source

File details

Details for the file slackybot-1.2.0.tar.gz.

File metadata

  • Download URL: slackybot-1.2.0.tar.gz
  • Upload date:
  • Size: 7.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.3

File hashes

Hashes for slackybot-1.2.0.tar.gz
Algorithm Hash digest
SHA256 9949b6f1fd0e3128babd244611a3a304db6b78dd79360cf0f5cefc741fb352d6
MD5 5786592088240b7697ec9867eca18104
BLAKE2b-256 d1128dfb3baeb55247d5c29cb317276e8b66e7b833ddead9df97ea9f1b262fd0

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 Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page