You are here

function slack_send_message in Slack 6

Same name and namespace in other branches
  1. 7 includes/slack.api.inc \slack_send_message()

Send message to the Slack.

Parameters

string $message: The message sent to the channel

string $channel: The channel in the Slack service to send messages

string $username: The bot name displayed in the channel

Return value

bool|object Slack response.

2 calls to slack_send_message()
slack_rules_send_message_action in ./slack.rules.inc
Rules action for sending a message to the Slack.
slack_send_test_message_form_submit in includes/pages/slack.pages.inc
Submit handler for slack test message form.

File

includes/slack.api.inc, line 21
Slack integration module API functions.

Code

function slack_send_message($message, $channel = '', $username = '') {
  $webhook_url = slack_get_default_webhook_url();
  if (!$webhook_url) {
    return FALSE;
  }
  $message_options = array();
  if ($channel) {
    $message_options['channel'] = $channel;
  }
  else {
    $message_options['channel'] = slack_get_default_channel();
  }
  if ($username) {
    $message_options['username'] = $username;
  }
  else {
    $message_options['username'] = slack_get_default_username();
  }
  $result = _slack_send_message($webhook_url, $message, $message_options);
  return $result;
}