def send_msg_v1(module, token, room, msg_from, msg, msg_format='text', color='yellow', notify=False, api=MSG_URI_V1):
 params = {}
 params['room_id'] = room
 params['from'] = msg_from[:15]
 params['message'] = msg
 params['message_format'] = msg_format
 params['color'] = color
 params['api'] = api
 params['notify'] = int(notify)
 url = ((api + MSG_URI_V1) + ('?auth_token=%s' % token))
 data = urllib.urlencode(params)
 if module.check_mode:
  module.exit_json(changed=False)
 (response, info) = fetch_url(module, url, data=data)
 if (info['status'] == 200):
  return response.read()
 else:
  module.fail_json(msg=('failed to send message, return status=%s' % str(info['status'])))

def send_msg_v1 ( module , token , room , msg_from , msg , msg_format = 'text' , color = 'yellow' , notify = False , api = MSG_URI_V1 ) : params = { } params [ 'room_id' ] = room params [ 'from' ] = msg_from [ : 15 ] params [ 'message' ] = msg params [ 'message_format' ] = msg_format params [ 'color' ] = color params [ 'api' ] = api params [ 'notify' ] = int ( notify ) url = ( ( api + MSG_URI_V1 ) + ( '?auth_token=%s' % token ) ) data = urllib . urlencode ( params ) if module . check_mode : module . exit_json ( changed = False ) ( response , info ) = fetch_url ( module , url , data = data ) if ( info [ 'status' ] == 200 ) : return response . read ( ) else : module . fail_json ( msg = ( 'failed to send message, return status=%s' % str ( info [ 'status' ] ) ) )
sending message to hipchat v1 server .