From f606bf329f923ca60be4c840b8dfa56aaa71d285 Mon Sep 17 00:00:00 2001 From: Ceda EI Date: Mon, 2 Jul 2018 22:42:19 +0530 Subject: [PATCH] Add /get and #requirements to message. --- webhook.php | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/webhook.php b/webhook.php index f654939..d4cf546 100644 --- a/webhook.php +++ b/webhook.php @@ -93,7 +93,7 @@ function add_requirement() { $stmt->execute(); $conn->close(); send_html("Added to requirements"); - get_updated_req(); + edit_html(get_updated_req()); } function deposit(){ @@ -114,7 +114,7 @@ function deposit(){ $stmt->execute(); $conn->close(); send_html("Deposited!"); - get_updated_req(); + edit_html(get_updated_req()); } function get_updated_req() { @@ -126,15 +126,15 @@ function get_updated_req() { $sql = "SELECT name, quantity FROM req WHERE quantity > 0;"; $result = $conn->query($sql); - $text = ""; + $text = "#requirements\n"; if ($result->num_rows > 0) { while($row = $result->fetch_assoc()) { $text .= $row["name"] . " " . $row["quantity"] . "\n"; } } else { - $text = "Everything is complete"; + $text .= "Everything is complete"; } - edit_html($text); + return $text; } function everyone() { @@ -147,6 +147,10 @@ function everyone() { send_html($text); } +function get_req() { + send_html(get_updated_req()); +} + // Get JSON from post, store it and decode it. $var = file_get_contents('php://input'); $decoded = json_decode($var); @@ -174,6 +178,10 @@ $modules = array( array( "command" => "/everyone", "function" => "everyone();" + ), + array( + "command" => "/get", + "function" => "get_req();" ) );