This commit is contained in:
Hannes Verschore 2015-11-07 06:12:58 -08:00
Родитель 8e2f319cdc
Коммит 1a18ccedc4
2 изменённых файлов: 2 добавлений и 28 удалений

Просмотреть файл

@ -40,33 +40,6 @@ function init_database()
mysql_select_db($config->mysql_db_name) or die("ERROR: " . mysql_error());
}
// (string) $message - message to be passed to Slack
// (string) $room - room in which to write the message, too
// (string) $icon - You can set up custom emoji icons to use with each message
function slack($message, $room = "engineering", $icon = ":longbox:")
{
global $config;
$room = ($room) ? $room : "engineering";
$data = "payload=" . json_encode(array(
#"channel" => "#{$room}",
"text" => $message,
"icon_emoji" => $icon
));
// You can get your webhook endpoint from your Slack settings
$url = $config->slack_webhook;
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
function username()
{
if (!isset($_SESSION['persona']))

Просмотреть файл

@ -8,6 +8,7 @@ require_once("internals.php");
require_once("lib/RetriggerController.php");
require_once("lib/DB/TaskQueue.php");
require_once("lib/DB/QueuedTask.php");
require_once("lib/Slack.php");
init_database();
@ -15,7 +16,7 @@ if ($unit = GET_int("unit")) {
$queue = new TaskQueue($unit);
if ($queue->has_active_task())
slack("requesting new task, while old task is still running!");
Slack::log("requesting new task, while old task is still running!");
if (!$queue->has_queued_tasks()) {
$retrigger = RetriggerController::fromUnit($unit);