
    Vh%                         d dl mZmZmZ eZdZdZd dlZd dl	Z	dZ
dZ	 d dlZd dlmZmZ d dlmZ d	 Zed
k(  r e        yy# e$ r  e	j                         ZdZ
Y 9w xY w)    )absolute_importdivisionprint_functiona  
module: jabber
short_description: Send a message to jabber user or chat room
description:
  - Send a message to jabber.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  user:
    type: str
    description:
      - User as which to connect.
    required: true
  password:
    type: str
    description:
      - Password for user to connect.
    required: true
  to:
    type: str
    description:
      - User ID or name of the room, when using room use a slash to indicate your nick.
    required: true
  msg:
    type: str
    description:
      - The message body.
    required: true
  host:
    type: str
    description:
      - Host to connect, overrides user info.
  port:
    type: int
    description:
      - Port to connect to, overrides default.
    default: 5222
  encoding:
    type: str
    description:
      - Message encoding.
requirements:
  - python xmpp (xmpppy)
author: "Brian Coca (@bcoca)"
aQ  
- name: Send a message to a user
  community.general.jabber:
    user: mybot@example.net
    password: secret
    to: friend@example.net
    msg: Ansible task finished

- name: Send a message to a room
  community.general.jabber:
    user: mybot@example.net
    password: secret
    to: mychaps@conference.example.net/ansiblebot
    msg: Ansible task finished

- name: Send a message, specifying the host and port
  community.general.jabber:
    user: mybot@example.net
    host: talk.example.net
    port: 5223
    password: secret
    to: mychaps@example.net
    msg: Ansible task finished
NTF)AnsibleModulemissing_required_lib)	to_nativec                     t        t        t        d      t        dd      t        d      t        d      t        d      t        ddd      t        d            d	      } t        s | j                  t	        d
      t
               t        j                  | j                  d         }|j                         }|j                         }| j                  d   }| j                  d   }	 | j                  d   j                  dd      \  }}| j                  d   r| j                  d   }n|}| j                  d   r"| j                  d   t        j                  _        t        j                  j!                  | j                  d         }		 t        j"                  |g       }
|
j%                  ||f      s| j                  dd|z         |
j'                  ||d      s| j                  dd|d|       |
j)                  d       |r|	j+                  d       |	j-                  d d!"       t        j.                  | j                  d   #      }|j-                  d d$"       |
j1                  |       t3        j4                  d       n|	j+                  d%       |	j7                  |       | j8                  s|
j1                  |	       t3        j4                  d       |
j;                          | jE                  d|||	jG                         '       y # t        $ r | j                  d   d }}Y 'w xY w# t<        $ r;}| j                  d&t?        |      z  tA        jB                                Y d }~d }~ww xY w)(NT)required)r
   no_logFif  int)r
   defaulttype)userpasswordtomsghostportencoding)argument_specsupports_check_modexmpppy)r   	exceptionr   r   r   r   /   r   r   r   )body)debug)serverzFailed to connect to server: %s)rcr   AnsiblezFailed to authorize z on: r   )requestRoster	groupchatxz#http://jabber.org/protocol/muc#user)	namespace)r   zhttp://jabber.org/protocol/mucchatzunable to send msg: %s)changedr   r   r   )$r   dictHAS_XMPP	fail_jsonr   XMPP_IMP_ERRxmppJIDparamsgetNode	getDomainsplit
ValueError	simplexmlENCODINGprotocolMessageClientconnectauthsendInitPresencesetTypesetTagPresencesendtimesleepsetTo
check_mode
disconnect	Exceptionr   	traceback
format_exc	exit_jsongetBody)modulejidr   r   r   r   r   nickr   r   connjoines                l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/jabber.pymainrO   g   s   t$45T"d#u%ud?5)
 !F 1(;|T
((6==(
)C;;=D]]_F== D}}Z(H-==&,,S!4D }}V}}V$}}Z "(--
";
--

V]]5%9

:Ch{{6,||D$<|0'HF'STyyx3$PV'WXA.KK$JJs&KJL==FMM$$78DKK'GKHIIdOJJqMKK		"  IIcN

1 Ur#++-HO  -==&D-H  h5	!DPYPdPdPfgghs+   ."L E&L; L87L8;	M?1M::M?__main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESr>   rD   r(   r*   r+   ImportErrorrE   ansible.module_utils.basicr   r   +ansible.module_utils.common.text.convertersr   rO   __name__     rN   <module>r[      s    A @1f2  
 K A@IF zF W  '9'')LHs   A AA