From e98e95d89939cdc1252d02df04ae8d91c6aa8c92 Mon Sep 17 00:00:00 2001 From: RaindropsSys Date: Mon, 27 Mar 2023 22:22:53 +0200 Subject: Updated 9 files, added 9 files, deleted 3 files and renamed includes/refresh/logo.inc (automated) --- includes/jobs/PKMembers.php | 48 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 includes/jobs/PKMembers.php (limited to 'includes/jobs/PKMembers.php') diff --git a/includes/jobs/PKMembers.php b/includes/jobs/PKMembers.php new file mode 100644 index 0000000..529a820 --- /dev/null +++ b/includes/jobs/PKMembers.php @@ -0,0 +1,48 @@ + [ + 'method' => 'GET', + 'header' => + "Authorization: " . $app["other"]["token"] . "\r\n" + ] + ]); +} else { + $ctx = stream_context_create([ + 'http' => [ + 'method' => 'GET' + ] + ]); +} + +$data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system/members", false, $ctx); + +if (trim($data) !== "" && $data !== false) { + $parsed = json_decode($data, true); + + foreach ($parsed as $index => $member) { + if (isset($member["avatar_url"])) { + $dominantColor = substr(ColorThief::getColor($member["avatar_url"], outputFormat: "hex"), 1); + } else { + $dominantColor = "ffffff"; + } + + $parsed[$index]["dominant_color"] = $dominantColor; + + if (!isset($member["color"])) { + $parsed[$index]["color"] = $dominantColor; + } + } + + $data = json_encode($parsed, JSON_PRETTY_PRINT); + file_put_contents("./data/$system/members.json", $data); +} \ No newline at end of file -- cgit