
    Vh                         d dl mZmZmZ eZdZdZdZd dl	Z	d dl
mZmZ dZ	 d dlmZ dZd
 Zd Zedk(  r e        yy# e$ r  e	j$                         Zd	ZY .w xY w)    )absolute_importdivisionprint_functionu  
author: "Jan Christian Grünhage (@jcgruenhage)"
module: matrix
short_description: Send notifications to matrix
description:
  - This module sends html formatted notifications to matrix rooms.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  msg_plain:
    type: str
    description:
      - Plain text form of the message to send to matrix, usually markdown.
    required: true
  msg_html:
    type: str
    description:
      - HTML form of the message to send to matrix.
    required: true
  room_id:
    type: str
    description:
      - ID of the room to send the notification to.
    required: true
  hs_url:
    type: str
    description:
      - URL of the homeserver, where the CS-API is reachable.
    required: true
  token:
    type: str
    description:
      - Authentication token for the API call. If provided, O(user_id) and O(password) are not required.
  user_id:
    type: str
    description:
      - The user ID of the user.
  password:
    type: str
    description:
      - The password to log in with.
requirements:
  - matrix-client (Python library)
a+  
- name: Send matrix notification with token
  community.general.matrix:
    msg_plain: "**hello world**"
    msg_html: "<b>hello world</b>"
    room_id: "!12345678:server.tld"
    hs_url: "https://matrix.org"
    token: "{{ matrix_auth_token }}"

- name: Send matrix notification with user_id and password
  community.general.matrix:
    msg_plain: "**hello world**"
    msg_html: "<b>hello world</b>"
    room_id: "!12345678:server.tld"
    hs_url: "https://matrix.org"
    user_id: "ansible_notification_bot"
    password: "{{ matrix_auth_password }}"

N)AnsibleModulemissing_required_lib)MatrixClientTFc                     t        t        dd      t        dd      t        dd      t        dd      t        ddd      t        dd      t        ddd            } t        dd      }t        | d	d
ggd	d
ggdd	ggd      }t        s |j                  t	        d      t
               |j                  r|S t        |j                  d         }|j                  d
   |j                  d
   |j                  _
        n.|j                  |j                  d   |j                  d	   d       |j                  |j                  d         }|j                  |j                  d   |j                  d           |j                  di | y )NstrT)typerequiredF)r   r   no_log)	msg_plainmsg_htmlroom_idhs_urltokenuser_idpassword )changedmessager   r   r   )argument_specmutually_exclusiverequired_one_ofrequired_togethersupports_check_modezmatrix-client)msg	exceptionr   )syncr   r   r    )dictr   matrix_found	fail_jsonr   MATRIX_IMP_ERR
check_moder	   paramsapir   login	join_room	send_html	exit_json)module_argsresultmoduleclientrooms        l/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/matrix.py
run_moduler3   `   sr   ED1540%$/.d;%%055>K F
 !'12$g./%z23 F 1/Bn] &--12F}}W)!==1

V]]9-v}}Z/HuU FMM)45DNN6==,fmmK.HIFv    c                      t                y )N)r3   r!   r4   r2   mainr6      s    Lr4   __main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURN	tracebackansible.module_utils.basicr   r   r%   matrix_client.clientr	   r#   ImportError
format_excr3   r6   __name__r!   r4   r2   <module>rC      s    C B0d&
  J1
 L*Z zF q  )Y))+NLs   > AA