Skip to content

Commit

Permalink
#49 implementation
Browse files Browse the repository at this point in the history
Added a couple new variables to control this, $usetimechan and
$firmalertchan
  • Loading branch information
jundis committed Oct 14, 2016
1 parent 3c6e7ae commit e7ba2a8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 14 deletions.
4 changes: 3 additions & 1 deletion config.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
$postcompany = 1; //Set to 1 if you want the Company to be posted in the clear text of the post (general what will be seen on IRC/XMPP)
$timeenabled = 0; //Set to 1 if you want to post all tickets past $timepast to a specific channel, $timechan
$timepast = 1.0; //Set to a time in hours where once reached all updates will post to #dispatch.
$timechan = "#dispatch"; //Set to a channel to post to for $timeenabled
$timechan = "#ticketstime"; //Set to a channel to post to for $timeenabled
//"Bad" variables to block certain things from coming through in cwslack-incoming.php. Separate by a pipe symbol | to have multiple.
$badboard = "Alerts"; //Set to any board name you want to fail, to avoid ticket creation/updates from this board posting to Slack.
$badstatus = "Closed|Canceled"; //Set to any status name you want to fail, to avoid ticket creation/updates with this status from posting to Slack.
Expand All @@ -63,6 +63,8 @@
//This uses the variables $webhookurl and $timechan from cwslack-incoming.php above.
$posttousers = 1; //When set, will post to the user whenever the appointment reminder is reached.
$posttochan = 1; //When set, will post to $timechan whenever the firm appointment starts.
$usetimechan = 1; //When set, this will use the $timechan variable instead of the one below.
$firmalertchan = "#dispatch"; //When you want to split time alerts and firm alerts into their own channels.

//cwslack-follow.php
$slackfollowtoken = "Slack Token Here"; //Set your token for the follow slash command
Expand Down
45 changes: 32 additions & 13 deletions cwslack-firmalerts.php
Original file line number Diff line number Diff line change
Expand Up @@ -162,19 +162,38 @@
}
if($posttochan==1) //If channel post is on
{
$postfieldspre = array(
"channel"=>$timechan, //Post to channel set in config.php
"attachments"=>array(array(
"fallback" => "Firm for " . $username . " with " . $company . " now.",
"title" => "<" . $ticketurl . $entry->objectId . "&companyName=" . $companyname . "|#" . $entry->objectId . ">: " . $summary,
"pretext" => $username . " has a firm starting now.",
"text" => "Please remind the technician of this appointment with " . $company . ". They should be on the phone with them or calling them shortly.",
"mrkdwn_in" => array(
"text",
"pretext"
)
))
);
if($usetimechan==1)
{
$postfieldspre = array(
"channel"=>$timechan, //Post to channel set in config.php
"attachments"=>array(array(
"fallback" => "Firm for " . $username . " with " . $company . " now.",
"title" => "<" . $ticketurl . $entry->objectId . "&companyName=" . $companyname . "|#" . $entry->objectId . ">: " . $summary,
"pretext" => $username . " has a firm starting now.",
"text" => "Please remind the technician of this appointment with " . $company . ". They should be on the phone with them or calling them shortly.",
"mrkdwn_in" => array(
"text",
"pretext"
)
))
);
}
else
{
$postfieldspre = array(
"channel"=>$firmalertchan, //Post to channel set in config.php
"attachments"=>array(array(
"fallback" => "Firm for " . $username . " with " . $company . " now.",
"title" => "<" . $ticketurl . $entry->objectId . "&companyName=" . $companyname . "|#" . $entry->objectId . ">: " . $summary,
"pretext" => $username . " has a firm starting now.",
"text" => "Please remind the technician of this appointment with " . $company . ". They should be on the phone with them or calling them shortly.",
"mrkdwn_in" => array(
"text",
"pretext"
)
))
);
}
$ch = curl_init();
$postfields = json_encode($postfieldspre);

Expand Down

0 comments on commit e7ba2a8

Please sign in to comment.