Sending Messages
django_slack_tools.slack_messages.message.slack_message(body, *, channel, header=None, raise_exception=False, get_permalink=False)
Send a simple text message.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
body |
str | MessageBody | dict[str, Any]
|
Message content, simple message or full request body. |
required |
channel |
str
|
Channel to send message. |
required |
header |
MessageHeader | dict[str, Any] | None
|
Slack message control header. |
None
|
raise_exception |
bool
|
Whether to re-raise caught exception while sending messages. |
False
|
get_permalink |
bool
|
Try to get the message permalink via extraneous Slack API calls. |
False
|
Returns:
Type | Description |
---|---|
SlackMessage | None
|
Sent message instance or |
Source code in django_slack_tools/slack_messages/message.py
django_slack_tools.slack_messages.message.slack_message_via_policy(policy, *, header=None, raise_exception=False, lazy=False, get_permalink=False, context=None)
Send a simple text message.
Mentions for each recipient will be passed to template as keyword {mentions}
.
Template should include it to use mentions.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
policy |
str | SlackMessagingPolicy
|
Messaging policy code or policy instance. |
required |
header |
MessageHeader | dict[str, Any] | None
|
Slack message control header. |
None
|
raise_exception |
bool
|
Whether to re-raise caught exception while sending messages. |
False
|
lazy |
bool
|
Decide whether try create policy with disabled, if not exists. |
False
|
get_permalink |
bool
|
Try to get the message permalink via extraneous Slack API calls. |
False
|
context |
dict[str, Any] | None
|
Dictionary to pass to template for rendering. |
None
|
Returns:
Type | Description |
---|---|
list[SlackMessage | None]
|
Sent message instance or |
Raises:
Type | Description |
---|---|
DoesNotExist
|
Policy for given code does not exists. |