
    Vh                         d dl mZmZmZ eZdZdZ	 d dlm	Z
 d dlmZ d dlmZ d	 Zed
k(  r e        yy# e$ r d dlZddZ
Y ,w xY w)    )absolute_importdivisionprint_functionaH  
module: campfire
short_description: Send a message to Campfire
description:
  - Send a message to Campfire.
  - Messages with newlines will result in a "Paste" message being sent.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  subscription:
    type: str
    description:
      - The subscription name to use.
    required: true
  token:
    type: str
    description:
      - API token.
    required: true
  room:
    type: str
    description:
      - Room number to which the message should be sent.
    required: true
  msg:
    type: str
    description:
      - The message body.
    required: true
  notify:
    type: str
    description:
      - Send a notification sound before the message.
    required: false
    choices:
      - 56k
      - bell
      - bezos
      - bueller
      - clowntown
      - cottoneyejoe
      - crickets
      - dadgummit
      - dangerzone
      - danielsan
      - deeper
      - drama
      - greatjob
      - greyjoy
      - guarantee
      - heygirl
      - horn
      - horror
      - inconceivable
      - live
      - loggins
      - makeitso
      - noooo
      - nyan
      - ohmy
      - ohyeah
      - pushit
      - rimshot
      - rollout
      - rumble
      - sax
      - secret
      - sexyback
      - story
      - tada
      - tmyk
      - trololo
      - trombone
      - unix
      - vuvuzela
      - what
      - whoomp
      - yeah
      - yodel

# informational: requirements for nodes
requirements: []
author: "Adam Garside (@fabulops)"
aE  
- name: Send a message to Campfire
  community.general.campfire:
    subscription: foo
    token: 12345
    room: 123
    msg: Task completed.

- name: Send a message to Campfire
  community.general.campfire:
    subscription: foo
    token: 12345
    room: 123
    notify: loggins
    msg: Task completed ... with feeling.
)escapeNc                 .    t        j                  | |      S )N)cgir   )textquotes     n/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/campfire.pyhtml_escaper   }   s    zz$&&    )AnsibleModule)	fetch_urlc                     t        t        t        d      t        dd      t        d      t        d      t        dg d            d      } | j                  d	   }| j                  d
   }| j                  d   }| j                  d   }| j                  d   }d|z  }d}d}d}	|| j                  d<   d| j                  d<   |d|d}
d|	d}|rAt        | |
|t	        |      z  |      \  }}|d   dvr| j                  d|d|d   d       t        | |
|t	        |      z  |      \  }}|d   dvr| j                  d|d|d   d       | j                  d|||        y )!NT)required)r   no_logF),56kbellbezosbueller	clowntowncottoneyejoecrickets	dadgummit
dangerzone	danielsandeeperdramagreatjobgreyjoy	guaranteeheygirlhornhorrorinconceivablelivelogginsmakeitsonoooonyanohmyohyeahpushitrimshotrolloutrumblesaxsecretsexybackstorytadatmyktrololotromboneunixvuvuzelawhatwhoompyeahyodel)r   choices)subscriptiontokenroommsgnotify)argument_specsupports_check_moder@   rA   rB   rC   rD   zhttps://%s.campfirenow.comz;<message><type>SoundMessage</type><body>%s</body></message>z"<message><body>%s</body></message>zAnsible/1.2url_usernameXurl_passwordz/room/z
/speak.xmlzapplication/xml)zContent-Typez
User-agent)dataheadersstatus)      zunable to send msg: 'z&', campfire api returned error code: '')rC   )changedrB   rC   rD   )r   dictparamsr   r   	fail_json	exit_json)moduler@   rA   rB   rC   rD   URINSTRMSTRAGENT
target_urlrK   responseinfos                 r   mainr]      s   t,T2t$d#!*+
* "-F2 ==0LMM'"E== D
--
C]]8$F
&
5CHD/DE %*FMM.!$'FMM.!+.5J0"$G "6:D;vCV<V`gh$>+"($x.": ;
 vz{3?O8OY`aNHdH~Z'!4>3 	4 T#fEr   __main__)T)
__future__r   r   r   type__metaclass__DOCUMENTATIONEXAMPLEShtmlr   r   ImportErrorr   ansible.module_utils.basicr   ansible.module_utils.urlsr   r]   __name__ r   r   <module>rj      sh    A @Xt"'* 5 /=F@ zF W  ''	's   5 AA