No project description provided
Project description
Slack Notifications Python
SlackNotifications is a lightweight, extensible Python library that simplifies sending rich notifications to Slack channels via incoming webhooks.
Installation
pip install slack-notifications-python
Quick Start
from typing import Dict, List
from traitlets import Any
from SlackNotifications.slack import (
SlackChannelConfig,
SlackNotificationService,
SlackNotificationServiceConfig,
)
class ExtendedSlackNotificationService(SlackNotificationService):
def __init__(self, config: SlackNotificationServiceConfig) -> None:
super().__init__(config)
def example_custom_method(
self, channel_reference: str, title: str, line1: str, line2: str, line3: str
) -> None:
blocks: List[Dict[str, Any]] = [
self.divider_block(),
self.section_block(self.bold_text(title)),
self.section_block(self.italic_text(line1)),
self.section_block(self.italic_text(line2)),
self.section_block(self.italic_text(line3)),
self.footer_block("Example Custom Message"),
]
self.send_message(channel_reference, blocks)
# Example configuration for slack channels
channel_configs = [
SlackChannelConfig(
channel_reference="alerts",
channel_webhook_url="https://hooks.slack.com/services/T00000000/B00000000/FAKEFAKEFAKEFAKEFAKEFAKE",
),
SlackChannelConfig(
channel_reference="notifications",
channel_webhook_url="https://hooks.slack.com/services/T00000000/B00000000/FAKEFAKEFAKEFAKEFAKEFAKE",
),
]
# Initialize the Slack notification service
service_config = SlackNotificationServiceConfig(
channels=channel_configs,
send_to_slack=True,
verbose=True,
)
# Initialise the extended service
slack_service = ExtendedSlackNotificationService(config=service_config)
# Example of sending a message
slack_service.example_custom_method(
channel_reference="alerts",
title="Alert Title",
line1="This is the first line of the alert.",
line2="This is the second line of the alert.",
line3="This is the third line of the alert.",
)
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file slack_notifications_python-0.1.2.tar.gz.
File metadata
- Download URL: slack_notifications_python-0.1.2.tar.gz
- Upload date:
- Size: 7.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6381b7f3c0de8872c41425068f9ef6a5c58653dc0e167728b4afc2475741f54b
|
|
| MD5 |
9151d84e26f842244a31803bdc02f99f
|
|
| BLAKE2b-256 |
796451b098afa6147c2c5cb59c2a116bed36556c4dcdee97c675cb94f516a6c1
|
Provenance
The following attestation bundles were made for slack_notifications_python-0.1.2.tar.gz:
Publisher:
publish.yml on M-JEFFRYES/slack-notifications-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slack_notifications_python-0.1.2.tar.gz -
Subject digest:
6381b7f3c0de8872c41425068f9ef6a5c58653dc0e167728b4afc2475741f54b - Sigstore transparency entry: 737282371
- Sigstore integration time:
-
Permalink:
M-JEFFRYES/slack-notifications-python@5166d17bba092eaa5273b21826ff05c4d20ff3d8 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/M-JEFFRYES
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5166d17bba092eaa5273b21826ff05c4d20ff3d8 -
Trigger Event:
push
-
Statement type:
File details
Details for the file slack_notifications_python-0.1.2-py3-none-any.whl.
File metadata
- Download URL: slack_notifications_python-0.1.2-py3-none-any.whl
- Upload date:
- Size: 9.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ea306a1f48779b471b2ad48807f57e7502ae66f1636d5b9e8ced966d8343c2a
|
|
| MD5 |
4775573e47c7115cc6a3308a356412b5
|
|
| BLAKE2b-256 |
26150e537e83da5061c057c32be354eb5b7128f0a032347e4ca11a88858bc9b8
|
Provenance
The following attestation bundles were made for slack_notifications_python-0.1.2-py3-none-any.whl:
Publisher:
publish.yml on M-JEFFRYES/slack-notifications-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
slack_notifications_python-0.1.2-py3-none-any.whl -
Subject digest:
5ea306a1f48779b471b2ad48807f57e7502ae66f1636d5b9e8ced966d8343c2a - Sigstore transparency entry: 737282372
- Sigstore integration time:
-
Permalink:
M-JEFFRYES/slack-notifications-python@5166d17bba092eaa5273b21826ff05c4d20ff3d8 -
Branch / Tag:
refs/tags/v0.1.2 - Owner: https://github.com/M-JEFFRYES
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@5166d17bba092eaa5273b21826ff05c4d20ff3d8 -
Trigger Event:
push
-
Statement type: