%PDF- %PDF-
Direktori : /usr/lib/python2.7/site-packages/salt/modules/ |
Current File : //usr/lib/python2.7/site-packages/salt/modules/telegram.pyo |
� ���^c @@ s� d Z d d l m Z d d l Z d d l m Z y d d l Z e Z Wn e k ra e Z n Xe j e � Z d Z d � Z d � Z d � Z d d d � Z d � Z d S( 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 ( t absolute_importN( t SaltInvocationErrort telegramc C@ s t s t St S( sZ Return virtual name of the module. :return: The virtual name of the module. ( t HAS_REQUESTSt Falset __virtualname__( ( ( s9 /usr/lib/python2.7/site-packages/salt/modules/telegram.pyt __virtual__ s c C@ s9 t d d � p t d d � } | s5 t d � � n | S( sl Retrieves and return the Telegram's configured chat id :return: String: the chat id string s config.gets telegram:chat_ids telegram.chat_ids No Telegram chat id found( t __salt__R ( t chat_id( ( s9 /usr/lib/python2.7/site-packages/salt/modules/telegram.pyt _get_chat_id+ s c C@ s9 t d d � p t d d � } | s5 t d � � n | S( sh Retrieves and return the Telegram's configured token :return: String: the token string s config.gets telegram:tokens telegram.tokens No Telegram token found( R R ( t token( ( s9 /usr/lib/python2.7/site-packages/salt/modules/telegram.pyt _get_token9 s c C@ sS | s t � } n | s$ t � } n | s: t j d � n t d | 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!" s message is a required option.t messageR R ( R R t logt errort _post_message( R R R ( ( s9 /usr/lib/python2.7/site-packages/salt/modules/telegram.pyt post_messageG s c C@ s� d j | � } t � } | r+ | | d <n | r>