Skip to content
Permalink
Browse files

Add bullet points to MS Teams webhook

  • Loading branch information...
NEMS Linux
NEMS Linux committed Mar 14, 2019
1 parent 1af6ded commit ce2abb21dd691d7dac3b19188dc64c241923f3b0
Showing with 7 additions and 44 deletions.
  1. +7 −44 webhook
51 webhook
@@ -75,52 +75,15 @@ if (strstr($webhook,'office.com')) { // MS Office 365 / Teams: https://docs.micr
$hookObject->type = 'AdaptiveCard';
$hookObject->version = '1.0';
$hookObject->username = 'NEMS ' . strtoupper($state);
$hookObject->image = $light_cdn . $color . '.png';

$formattedIssues = '';
foreach(preg_split("/((\r?\n)|(\r\n?))/", $currentissues) as $line){
$formattedIssues .= trim($line) . "\r\n";
}

// For now, have to do plain text since Adaptive Cards don't work in MS Teams [yet] - see https://stackoverflow.com/questions/50753072/microsoft-teams-webhook-generating-400-for-adaptive-card#comment93907448_50753413
$hookObject->text = "**$nemsstate**\n\n" . str_replace(PHP_EOL,'\n\n',$currentissues) . "\n\n**Reporting Server:** $alias\n\n**Timestamp:** " . date('c') . "\n\nPowered by NEMS Linux $nemsver";

// The card below won't do anything until MS Teams supports adaptive cards... See note and link above.
$hookObject->body = array();
$hookObject->body[0] = array();
$hookObject->body[0]['type'] = 'ColumnSet';
$hookObject->body[0]['spacing'] = 'large';

$hookObject->body[0]['columns'] = array();

$hookObject->body[0]['columns'][0]['width'] = '32px';
$hookObject->body[0]['columns'][0]['items'] = array();

$hookObject->body[0]['columns'][0]['items'][0]['type'] = 'Image';
$hookObject->body[0]['columns'][0]['items'][0]['width'] = '16px';
$hookObject->body[0]['columns'][0]['items'][0]['horizontalAlignment'] = 'center';
$hookObject->body[0]['columns'][0]['items'][0]['url'] = $light_cdn . $color . '.png';
$hookObject->body[0]['columns'][0]['items'][0]['altText'] = strtoupper($state);

$hookObject->body[0]['columns'][1]['width'] = 'stretch';
$hookObject->body[0]['columns'][1]['items'] = array();

$hookObject->body[0]['columns'][1]['items'][0] = array();
$hookObject->body[0]['columns'][1]['items'][0]['type'] = 'TextBlock';
$hookObject->body[0]['columns'][1]['items'][0]['text'] = '**' . $nemsstate . '**';

$hookObject->body[0]['columns'][1]['items'][1] = array();
$hookObject->body[0]['columns'][1]['items'][1]['type'] = 'TextBlock';
$hookObject->body[0]['columns'][1]['items'][1]['text'] = $currentissues;

$hookObject->body[0]['columns'][1]['items'][2] = array();
$hookObject->body[0]['columns'][1]['items'][2]['type'] = 'TextBlock';
$hookObject->body[0]['columns'][1]['items'][2]['text'] = '**Reporting Server:** ' . $alias;

$hookObject->body[0]['columns'][1]['items'][3] = array();
$hookObject->body[0]['columns'][1]['items'][3]['type'] = 'TextBlock';
$hookObject->body[0]['columns'][1]['items'][3]['spacing'] = 'none';
$hookObject->body[0]['columns'][1]['items'][3]['text'] = '**Timestamp:** ' . date('c');

$hookObject->body[0]['columns'][1]['items'][4] = array();
$hookObject->body[0]['columns'][1]['items'][4]['type'] = 'TextBlock';
$hookObject->body[0]['columns'][1]['items'][4]['isSubtle'] = 'true';
$hookObject->body[0]['columns'][1]['items'][4]['spacing'] = 'small';
$hookObject->body[0]['columns'][1]['items'][4]['text'] = 'Powered by NEMS Linux ' . $nemsver;
$hookObject->text = "**$nemsstate**\n\n" . $formattedIssues . "\n\n**Reporting Server:** $alias\n\n**Timestamp:** " . date('c') . "\n\nPowered by NEMS Linux $nemsver";

} elseif (strstr($webhook,'slack.com')) { // Slack

0 comments on commit ce2abb2

Please sign in to comment.
You can’t perform that action at this time.