Change slack format to attachment style

As documented here: https://api.slack.com/docs/message-attachments

This change also makes things compatible with simple HTML templates by using strip_tags() on the template output.
This commit is contained in:
pblasquez
2016-07-19 15:15:07 -07:00
committed by GitHub
parent e9bce1d322
commit cf9432330e

View File

@@ -24,8 +24,17 @@
foreach( $opts as $tmp_api ) {
$host = $tmp_api['url'];
$curl = curl_init();
$slack_msg = strip_tags($obj['msg']);
$color = ($obj['state'] == 0 ? '#00FF00' : '#FF0000');
$data = array(
'text' => $obj['msg'],
'attachments' => array(
0 => array(
'fallback' => $slack_msg,
'color' => $color,
'title' => $obj['title'],
'text' => $slack_msg,
)
),
'channel' => $tmp_api['channel'],
'username' => $tmp_api['username'],
'icon_url' => $tmp_api['icon_url'],