Simple internal Slack API wrapper
Project description
ritdu-slacker
pip installable bin to interact with the Ringier SA internal interface for slack. Provides both CLI and Native python lib functionality.
Motivation
- Single implementation of a wrapper around our internal slack interface.
Installation
$ pip install ritdu-slacker
Usage
CLI
To send a message to a slack channel from within a thread:
$ ritdu-slacker message --workspace "${SLACK_WORKSPACE}" --channel "${SLACK_CHANNEL//#}" --text "Update in progress" --thread-uuid "${thread_uuid}" --thread-broadcast
To replace a message send a new one with the same message-uuid:
$ ritdu-slacker message --workspace "${SLACK_WORKSPACE}" --channel "${SLACK_CHANNEL//#}" --text "Update complete!" --message-uuid "${message_uuid}"
To send a message and file to a thread in a slack channel:
$ ritdu-slacker file --workspace "${SLACK_WORKSPACE}" --channel "${SLACK_CHANNEL//#}" --text "Oops!" --file "/tmp/errorlog.txt" --thread-uuid "${thread_uuid}"
To send a jsonblob to slack:
$ ritdu-slacker message --text '{ "blocks": [ { "type": "section", "text": { "type": "mrkdwn", "text": "Hello, Assistant to the Regional Manager Dwight! *Michael Scott* wants to know where youd like to take the Paper Company investors to dinner tonight.\n\n *Please select a restaurant:*" } }, { "type": "divider" }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Farmhouse aThai Cuisine*\n:star::star::star::star: 1528 reviews\n They do have some vegan options, like the roti and curry, plus they have a ton of salad stuff and noodles can be ordered without meat!! They have something for everyone here" }, "accessory": { "type": "image", "image_url": "https://s3-media3.fl.yelpcdn.com/bphoto/c7ed05m9lC2EmA3Aruue7A/o.jpg", "alt_text": "alt text for image" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Kin Khao*\n:star::star::star::star: 1638 reviews\n The sticky rice also goes wonderfully with the caramelized pork belly, which is absolutely melt-in-your-mouth and so soft." }, "accessory": { "type": "image", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/korel-1YjNtFtJlMTaC26A/o.jpg", "alt_text": "alt text for image" } }, { "type": "section", "text": { "type": "mrkdwn", "text": "*Ler Ros*\n:star::star::star::star: 2082 reviews\n I would really recommend the Yum Koh Moo Yang - Spicy lime dressing and roasted quick marinated pork shoulder, basil leaves, chili & rice powder." }, "accessory": { "type": "image", "image_url": "https://s3-media2.fl.yelpcdn.com/bphoto/DawwNigKJ2ckPeDeDM7jAg/o.jpg", "alt_text": "alt text for image" } }, { "type": "divider" } ] }' --command 'SlackJson' --workspace "ringier-southafrica" --channel "pe-test"
Python
from ritdu_slacker.api import SlackClient
client = SlackClient()
client.post_message("via python api","ringier-southafrica","#pe-alerts")
{'message_uuid': '9890b802-fac3-4e61-bbe8-b53cc17fc581', 'message_ts': '1677473299.255969', 'thread_uuid': '9890b802-fac3-4e61-bbe8-b53cc17fc581', 'thread_ts': '1677473299.255969', 'channel': 'CV3JFH08J'}
client.post_message(datajson,"ringier-southafrica","pe-test",command="SlackJson")
Development
To setup your development environment:
$ make setup-dev
Running make on its own generates help documentation:
$ make
build Build the package
check Check the package
clean Clean the package
format Format the code
install-dev Setup development environment
install-prod Install production dependencies
install Install all dependencies
lint Lint the code
lock Update dependency lockfile
publish-test Publish to the package to the PyPI test platform
publish Publish the package
setup-binaries Setup binaries for development. Poetry, Twine.
test Test the package
vscode Update VSCode settings
Please read the Makefile to see what each task does.
Deployment
To deploy a new version of the package to PyPI, you need to bump the version in the pyproject.toml file and then push the tag (prefixed by v) to the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file ritdu_slacker-1.5.2.tar.gz
.
File metadata
- Download URL: ritdu_slacker-1.5.2.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2aca8726138b46e3dfb870c18833b4f4d60320dd6192e165f44b770841cc409 |
|
MD5 | d0e8a4e7460b1376270086fa42c635d1 |
|
BLAKE2b-256 | aae976489826ea81aeefdbde1dd7814a61240ec47a9e145b96632926959ac459 |
File details
Details for the file ritdu_slacker-1.5.2-py3-none-any.whl
.
File metadata
- Download URL: ritdu_slacker-1.5.2-py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.10.12 Linux/6.5.0-1018-azure
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ac56d10112a69073735a1982426f76382e0400d668e5d9c99c71641e34eebcd0 |
|
MD5 | f99d654e6a2c05a8c5b849ff3c6d95d9 |
|
BLAKE2b-256 | caedfd3bba2915cfdfc4c31de3db21886e8321f3cc2aa24fdb960cc0ca1b83ff |