-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebhook.php
29 lines (20 loc) · 907 Bytes
/
webhook.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
<?php
include __DIR__.'/vendor/autoload.php';
use RestCord\DiscordClient;
define("DISCORD_TOKEN", null);
define("DISCORD_CHANNEL", null);
$json_data = file_get_contents("php://input");
if (empty($json_data) || empty(DISCORD_CHANNEL) || empty(DISCORD_TOKEN))
die();
$response = new FreshpingResponse($json_data);
$client = new DiscordClient(['token' => DISCORD_TOKEN]);
$checkAt = $response->getWebhookEventData()->getRequestStartTime();
$checkAt->setTimezone(new DateTimeZone(date_default_timezone_get()));
$message = ":bell: **" . $response->getWebhookEventData()->getCheckName() . ":** " .
$response->getWebhookEventData()->getCheckStateName() . " (" .
$checkAt->format('Y-m-d H:i:s') . ") - Response time: {$response->getWebhookEventData()->getResponseTime()} ms";
$client->channel->createMessage([
'channel.id' => DISCORD_CHANNEL,
'content' => $message
]);
?>