Commit notify script
authorCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 06:49:13 +0000 (14:49 +0800)
committerCameron Ball <cameron@moodle.com>
Tue, 7 May 2019 06:49:13 +0000 (14:49 +0800)
src/notifyrebuild.php [new file with mode: 0644]

diff --git a/src/notifyrebuild.php b/src/notifyrebuild.php
new file mode 100644 (file)
index 0000000..eed98b0
--- /dev/null
@@ -0,0 +1,35 @@
+<?php declare(strict_types=1);
+
+(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('cli only');
+
+require_once('common.php');
+
+$id = $argv[1];
+$what = $argv[2];
+
+if ($what == "hashdone") {
+    getTelegram()->sendMessage(
+        [
+            'chat_id' => $id,
+            'text' => 'Hash list rebuild completed, processing deltas...'
+        ]
+    );
+}
+
+if ($what == "deltasdone") {
+    getTelegram()->sendMessage(
+        [
+            'chat_id' => $id,
+            'text' => "Rebuild complete. " . $argv[3] . " additions, " . $argv[4] . " deletions, and " . $argv[5] . " moves."
+        ]
+    );
+}
+
+if ($what == "nochange") {
+    getTelegram()->sendMessage(
+        [
+            'chat_id' => $id,
+            'text' => "Rebuild complete. No changes detected."
+        ]
+    );
+}