HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/states/__pycache__/slack.cpython-310.pyc
o

�N�g��@s$dZddlmZdd�Zdd�ZdS)a(
Send a message to Slack
=======================

This state is useful for sending messages to Slack during state runs.

.. versionadded:: 2015.5.0

.. code-block:: yaml

    slack-message:
      slack.post_message:
        - channel: '#general'
        - from_name: SuperAdmin
        - message: 'This state was executed successfully.'
        - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15

The api key can be specified in the master or minion configuration like below:

.. code-block:: yaml

    slack:
      api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15

�)�SaltInvocationErrorcCsdtvrdSdS)z@
    Only load if the slack module is available in __salt__
    �slack.post_messageZslack)Fz slack module could not be loaded)�__salt__�rr�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/slack.py�__virtual__srcKs|iddd�}|�d�}|�d�}|s7|s7tdd�p tdd�}|s7tdd	�p.tdd
�}|s7d|d<|S|rA|rAd
|d<|S|rN|�d�sNd|d<|S|r[|�d�s[d|d<|S|�d�sfd|d<|Stdrzd�|�d��|d<d|d<|SzH|r�td|�d�|�d�|�d�|�d�|�d�d�}n)|r�td|�d�|�d�|�dd�|�d�|�d�|�d�|�d �|�d!�d"�}Wnty�}zd#|�d$|��|d<WYd}~|Sd}~wwt|t�r�|r�d%|d<d&|��|d<|Sd'�|d|�|d<|S)(ay
    Send a message to a Slack channel.

    .. code-block:: yaml

        slack-message:
          slack.post_message:
            - channel: '#general'
            - from_name: SuperAdmin
            - message: 'This state was executed successfully.'
            - api_key: peWcBiMOS9HrZG15peWcBiMOS9HrZG15

    The following parameters are required:

    api_key parameters:
        name
            The unique name for this event.

        channel
            The channel to send the message to. Can either be the ID or the name.

        from_name
            The name of that is to be shown in the "from" field.

        message
            The message that is to be sent to the Slack channel.

        The following parameters are optional:

        api_key
            The api key for Slack to use for authentication,
            if not specified in the configuration options of master or minion.

        icon
            URL to an image to use as the icon for this message

    webhook parameters:
        name
            The unique name for this event.

        message
            The message that is to be sent to the Slack channel.

        color
            The color of border of left side

        short
            An optional flag indicating whether the value is short
            enough to be displayed side-by-side with other values.

        webhook
            The identifier of WebHook (URL or token).

        channel
            The channel to use instead of the WebHook default.

        username
            Username to use instead of WebHook default.

        icon_emoji
            Icon to use instead of WebHook default.
    F�)�nameZchanges�result�comment�api_key�webhookz
config.getz
slack.api_keyz
slack:api_keyz
slack.hookz
slack:hookz"Please specify api_key or webhook.rz.Please specify only either api_key or webhook.�channelzSlack channel is missing.�	from_namezSlack from name is missing.�messagezSlack message is missing.�testz0The following message is to be sent to Slack: {}Nr
r�icon)rrrrrzslack.call_hook�
attachment�colorZgood�short�username�
icon_emoji)rrrrZ
identifierrrrzFailed to send message (z): TzSent message: zFailed to send message ({}): {})�getrZ__opts__�formatr�
isinstance�bool)r	�kwargs�retrr
r
Zsierrr�post_message's�?

��
��
��
����rN)�__doc__Zsalt.exceptionsrrrrrrr�<module>s