%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/modules/telegram.pyc

�
���^c@@s�dZddlmZddlZddlmZyddlZeZWne	k
rae
ZnXeje�Z
dZd�Zd�Zd�Zddd	�Zd
�ZdS(s[
Module for sending messages via Telegram.

:configuration: In order to send a message via the Telegram, certain
    configuration is required in /etc/salt/minion on the relevant minions or
    in the pillar. Some sample configs might look like::

        telegram.chat_id: '123456789'
        telegram.token: '00000000:xxxxxxxxxxxxxxxxxxxxxxxx'

i(tabsolute_importN(tSaltInvocationErrorttelegramcC@sts
tStS(sZ
    Return virtual name of the module.

    :return: The virtual name of the module.
    (tHAS_REQUESTStFalset__virtualname__(((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pyt__virtual__ scC@s9tdd�ptdd�}|s5td��n|S(sl
    Retrieves and return the Telegram's configured chat id

    :return:    String: the chat id string
    s
config.getstelegram:chat_idstelegram.chat_idsNo Telegram chat id found(t__salt__R(tchat_id((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pyt_get_chat_id+s
cC@s9tdd�ptdd�}|s5td��n|S(sh
    Retrieves and return the Telegram's configured token

    :return:    String: the token string
    s
config.getstelegram:tokenstelegram.tokensNo Telegram token found(RR(ttoken((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pyt
_get_token9s
cC@sS|st�}n|s$t�}n|s:tjd�ntd|d|d|�S(s�
    Send a message to a Telegram chat.

    :param message: The message to send to the Telegram chat.
    :param chat_id: (optional) The Telegram chat id.
    :param token:   (optional) The Telegram API token.
    :return:        Boolean if message was sent successfully.


    CLI Example:

    .. code-block:: bash

        salt '*' telegram.post_message message="Hello Telegram!"

    smessage is a required option.tmessageRR
(R	Rtlogterrort
_post_message(RRR
((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pytpost_messageGscC@s�dj|�}t�}|r+||d<n|r>||d<ny;tj|d|�}|j�}tjdj|��Wntk
r�tjd�t	SX|j
dt	�s�tjdj|j
d	�|j
d
���t	StS(s
    Send a message to a Telegram chat.

    :param chat_id:     The chat id.
    :param message:     The message to send to the telegram chat.
    :param token:       The Telegram API token.
    :return:            Boolean if message was sent successfully.
    s+https://api.telegram.org/bot{0}/sendMessageRttexttdatas+Raw response of the telegram request is {0}s#Sending telegram api request failedtoks:Sending telegram api request failed due to error {0} ({1})t
error_codetdescription(tformattdicttrequeststposttjsonR
tdebugt	Exceptiont	exceptionRtgettTrue(RRR
turlt
parameterstresponsetresult((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pyRds.		

	
(t__doc__t
__future__Rtloggingtsalt.exceptionsRRRRtImportErrorRt	getLoggert__name__R
RRR	RtNoneRR(((s9/usr/lib/python2.7/site-packages/salt/modules/telegram.pyt<module>s


			

Zerion Mini Shell 1.0