def call_hook(message, attachment=None, color='good', short=False, identifier=None, channel=None, username=None, icon_emoji=None):
 base_url = 'https://hooks.slack.com/services/'
 if (not identifier):
  identifier = _get_hook_id()
 url = _urljoin(base_url, identifier)
 if (not message):
  log.error('message is required option')
 if attachment:
  payload = {'attachments': [{'fallback': message, 'color': color, 'pretext': message, 'fields': [{'value': attachment, 'short': short}]}]}
 else:
  payload = {'text': message}
 if channel:
  payload['channel'] = channel
 if username:
  payload['username'] = username
 if icon_emoji:
  payload['icon_emoji'] = icon_emoji
 data = _urlencode({'payload': json.dumps(payload, ensure_ascii=False)})
 result = salt.utils.http.query(url, method='POST', data=data, status=True)
 if (result['status'] <= 201):
  return True
 else:
  return {'res': False, 'message': result.get('body', result['status'])}

def call_hook ( message , attachment = None , color = 'good' , short = False , identifier = None , channel = None , username = None , icon_emoji = None ) : base_url = 'https://hooks.slack.com/services/' if ( not identifier ) : identifier = _get_hook_id ( ) url = _urljoin ( base_url , identifier ) if ( not message ) : log . error ( 'message is required option' ) if attachment : payload = { 'attachments' : [ { 'fallback' : message , 'color' : color , 'pretext' : message , 'fields' : [ { 'value' : attachment , 'short' : short } ] } ] } else : payload = { 'text' : message } if channel : payload [ 'channel' ] = channel if username : payload [ 'username' ] = username if icon_emoji : payload [ 'icon_emoji' ] = icon_emoji data = _urlencode ( { 'payload' : json . dumps ( payload , ensure_ascii = False ) } ) result = salt . utils . http . query ( url , method = 'POST' , data = data , status = True ) if ( result [ 'status' ] <= 201 ) : return True else : return { 'res' : False , 'message' : result . get ( 'body' , result [ 'status' ] ) }
send message to slack incomming webhook .