API Documentation¶
-
class
jarjar.
jarjar
(message=None, channel=None, webhook=None)¶ A jarjar slack messenger.
This is largely a wrapper around functionality in
requests.post()
with facilities to store and set default values for the desired message to send, channel to post within, and slack team webhook.Inference for these values proceeds as follows.
- Any argument provided to
text()
orattach()
supersedes all defaults. - Defaults can be provided at initialization or via a config file
(
~/.jarjar
), which looks like:
channel="@username" message="Custom message" webhook="https://hooks.slack.com/services/your/teams/webhook"
- Arguments provided at initialization supersede those in
~/.jarjar
. If the channel or webhook arguments are never provided, an error is raised. If the channel and webhook are provided but not a message or attachment, jarjar will make something up.
Parameters: - message : str
Optional. Default message to send.
- channel : str, list
Optional. Name of the default channel to post within.
- webhook : str
Optional. Webhook URL for the default slack team.
Methods
attach(attach, channel=None, webhook=None, message=None) Send an attachment. User may also include a text message. text(message, channel=None, webhook=None, attach=None) Send a text message. User may also include an attachment. set_webhook(webhook) Set jarjar’s default webhook. set_channel(channel) Set jarjar’s default channel. set_message(message) Set jarjar’s default message. -
attach
(attach=None, **kwargs)¶ Send an attachment.
This method is largely identical to
text()
, only differing in the first argument (attach
), which is expected to be a dictionary.Parameters: - attach : dict
Attachment data. Optional but weird if you don’t provide one. All values are converted to string for the slack payload so don’t sweat it.
- message : str
Text to send. Optional. If attach is None and there is no default and you don’t provide one here, jarjar just wings it.
- channel : str, list
Optional. Name of the channel to post within. Can also be a list of channel names; jarjar will post to each.
- webhook : str
Optional. Webhook URL for the slack team.
Returns: - response : requests.models.Response
Requests response object for the POST request to slack.
-
set_channel
(channel)¶ Set default channel.
Parameters: - channel : str
Name of the channel to post within.
-
set_message
(message)¶ Set default message.
Parameters: - message : str
Default message to send.
-
set_webhook
(webhook)¶ Set default webhook.
Parameters: - webhook : str
Webhook URL for the slack team.
-
text
(message=None, **kwargs)¶ Send a text message.
This method is largely identical to
attach()
, only differing in the first argument (message
), which is expected to be a string.Parameters: - message : str
Text to send. Optional but weird if you don’t provide one. If attach is None and there is no default and you don’t provide one here, jarjar just wings it.
- attach : dict
Attachment data. Optional. All values are converted to string for the slack payload so don’t sweat it.
- channel : str, list
Optional. Name of the channel to post within. Can also be a list of channel names; jarjar will post to each.
- webhook : str
Optional. Webhook URL for the slack team.
Returns: - response : requests.models.Response
Requests response object for the POST request to slack.
- Any argument provided to