diff options
author | RaindropsSys <contact@minteck.org> | 2023-04-02 23:03:02 +0200 |
---|---|---|
committer | RaindropsSys <contact@minteck.org> | 2023-04-02 23:03:02 +0200 |
commit | 02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b (patch) | |
tree | 6d1dec61008998aadc6b69f7e750712794d99324 /includes/jobs | |
parent | f559308a1b42a9036135d764374a8c007b7d70a9 (diff) | |
download | pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.gz pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.tar.bz2 pluralconnect-02eda3e4c9b4ba718f1fff70b7328ed8cdd5e63b.zip |
Updated 35 files, added 11 files and deleted includes/components/search.inc (automated)
Diffstat (limited to 'includes/jobs')
-rw-r--r-- | includes/jobs/FrontersNotification.php | 18 | ||||
-rw-r--r-- | includes/jobs/PKMembers.php | 9 | ||||
-rw-r--r-- | includes/jobs/PKSystem.php | 2 | ||||
-rw-r--r-- | includes/jobs/UpdateAssets.php | 4 |
4 files changed, 22 insertions, 11 deletions
diff --git a/includes/jobs/FrontersNotification.php b/includes/jobs/FrontersNotification.php index d95f273..f29a1e5 100644 --- a/includes/jobs/FrontersNotification.php +++ b/includes/jobs/FrontersNotification.php @@ -5,6 +5,12 @@ $_SERVER['DOCUMENT_ROOT'] = "../.."; require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/composer/vendor/autoload.php'; use ColorThief\ColorThief; +if (!function_exists("formatPonypush")) { + function formatPonypush($message) { + return "Update to Ponypush 3.1.0 or later — (\$PA1$\$" . base64_encode($message) . "\$\$)"; + } +} + $app = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/app.json"), true); $system = $options["system"]; @@ -48,12 +54,12 @@ if (count($fronters["members"]) > 1) { 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in $name\r\n" . + "Title: " . formatPonypush("🐴 Switch occurred in $name") . "\r\n" . "Priority: default\r\n" . "Tags: switch\r\n" . "Actions: view, Open " . $fronters["members"][0]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true;view, Open " . $fronters["members"][1]["display_name"] . " on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][1]["name"] . "/, clear=true\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now" + 'content' => formatPonypush(($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " and " . ($fronters["members"][1]["display_name"] ?? $fronters["members"][1]["name"]) . " switched in just now") ] ]); } else if (count($fronters["members"]) > 0) { @@ -62,12 +68,12 @@ if (count($fronters["members"]) > 1) { 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in $name\r\n" . + "Title: " . formatPonypush("🐴 Switch occurred in $name") . "\r\n" . "Priority: default\r\n" . "Tags: switch\r\n" . "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/" . $fronters["members"][0]["name"] . "/, clear=true\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => ($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now" + 'content' => formatPonypush(($fronters["members"][0]["display_name"] ?? $fronters["members"][0]["name"]) . " switched in just now") ] ]); } else { @@ -76,12 +82,12 @@ if (count($fronters["members"]) > 1) { 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . - "Title: 🐴 Switch occurred in $name\r\n" . + "Title: " . formatPonypush("🐴 Switch occurred in $name") . "\r\n" . "Priority: default\r\n" . "Tags: switch\r\n" . "Actions: view, Open on Cold Haze, https://ponies.equestria.horse/, clear=true\r\n" . "Authorization: Basic " . base64_encode($ntfy["user"] . ":" . $ntfy["password"]), - 'content' => "The fallback pony switched in just now" + 'content' => formatPonypush("The fallback pony switched in just now") ] ]); } diff --git a/includes/jobs/PKMembers.php b/includes/jobs/PKMembers.php index 529a820..536853d 100644 --- a/includes/jobs/PKMembers.php +++ b/includes/jobs/PKMembers.php @@ -30,6 +30,8 @@ if (trim($data) !== "" && $data !== false) { $parsed = json_decode($data, true); foreach ($parsed as $index => $member) { + echo(($member["display_name"] ?? $member["name"]) . "\n"); + if (isset($member["avatar_url"])) { $dominantColor = substr(ColorThief::getColor($member["avatar_url"], outputFormat: "hex"), 1); } else { @@ -44,5 +46,8 @@ if (trim($data) !== "" && $data !== false) { } $data = json_encode($parsed, JSON_PRETTY_PRINT); - file_put_contents("./data/$system/members.json", $data); -}
\ No newline at end of file + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/members.json", $data); +} + +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/navigation.json", "{}"); +file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/cache/home.json", "{}");
\ No newline at end of file diff --git a/includes/jobs/PKSystem.php b/includes/jobs/PKSystem.php index c3fce1b..045eb67 100644 --- a/includes/jobs/PKSystem.php +++ b/includes/jobs/PKSystem.php @@ -27,5 +27,5 @@ if ($app["other"]["id"] === $system) { $data = file_get_contents("https://pluralkit.equestria.dev/v2/systems/$system", false, $ctx); if (trim($data) !== "" && $data !== false) { - file_put_contents("./data/$system/general.json", $data); + file_put_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$system/general.json", $data); }
\ No newline at end of file diff --git a/includes/jobs/UpdateAssets.php b/includes/jobs/UpdateAssets.php index 8898b94..e52a6fa 100644 --- a/includes/jobs/UpdateAssets.php +++ b/includes/jobs/UpdateAssets.php @@ -19,7 +19,7 @@ function downloadAssets($system, $path = null) { $path = $system; } - $general = json_decode(file_get_contents("./data/$path/general.json"), true); + $general = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$path/general.json"), true); if ($options["type"] === "system") { if (isset($general["avatar_url"])) { @@ -39,7 +39,7 @@ function downloadAssets($system, $path = null) { } } - $members = json_decode(file_get_contents("./data/$path/members.json"), true); + $members = json_decode(file_get_contents($_SERVER['DOCUMENT_ROOT'] . "/includes/data/$path/members.json"), true); foreach ($members as $member) { $id = preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $general["uuid"]) . preg_replace("/^([\da-f]{8})-([\da-f]{4})-([\da-f]{4})-([\da-f]{4})-([\da-f]{12})$/", "$1$2$3$4$5", $member["uuid"]); |