From 14b415bc33a071149f506d4d8e6e6438b5e3223e Mon Sep 17 00:00:00 2001 From: TeoCZ Date: Sat, 30 Nov 2019 23:28:31 +0100 Subject: [PATCH 1/6] Add files via upload --- SEContestChatCommands.php | 9 +++++++-- SEContestChatCommands.refund.php | 15 +++++++++++++++ 2 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 SEContestChatCommands.refund.php diff --git a/SEContestChatCommands.php b/SEContestChatCommands.php index 6d64f7a..55af02c 100644 --- a/SEContestChatCommands.php +++ b/SEContestChatCommands.php @@ -14,6 +14,7 @@ require_once("SEContestChatCommands.close.php"); require_once("SEContestChatCommands.latest.php"); require_once("SEContestChatCommands.pick.php"); + require_once("SEContestChatCommands.refund.php"); switch(strtolower($_GET["action"])) { @@ -57,7 +58,7 @@ case "close": CloseContest($channel, $bearer, GetActiveId($channel, $bearer)); - break; + break; case "draw": if (isset($_GET["winner"]) && trim($_GET["winner"]) != "") @@ -76,8 +77,12 @@ echo "Wrong format! Expected !bets draw winningOption"; break; + case "refund": + RefundContest($channel, $bearer, GetLatestId($channel, $bearer)); + break; + default: - echo "Invalid action! Expected: start|close|draw"; + echo "Invalid action! Expected: start|close|draw|refund"; } } else diff --git a/SEContestChatCommands.refund.php b/SEContestChatCommands.refund.php new file mode 100644 index 0000000..31f0a10 --- /dev/null +++ b/SEContestChatCommands.refund.php @@ -0,0 +1,15 @@ + Date: Mon, 9 Dec 2019 16:58:37 +0100 Subject: [PATCH 2/6] Renamed files Renamed redundant parts of file names --- .gitignore | 2 +- SEContestChatCommands.php | 18 +++++++++--------- SEContestChatCommands.active.php => active.php | 0 SEContestChatCommands.close.php => close.php | 0 SEContestChatCommands.latest.php => latest.php | 0 SEContestChatCommands.open.php => open.php | 0 SEContestChatCommands.option.php => option.php | 0 SEContestChatCommands.pick.php => pick.php | 0 SEContestChatCommands.refund.php => refund.php | 0 9 files changed, 10 insertions(+), 10 deletions(-) rename SEContestChatCommands.active.php => active.php (100%) rename SEContestChatCommands.close.php => close.php (100%) rename SEContestChatCommands.latest.php => latest.php (100%) rename SEContestChatCommands.open.php => open.php (100%) rename SEContestChatCommands.option.php => option.php (100%) rename SEContestChatCommands.pick.php => pick.php (100%) rename SEContestChatCommands.refund.php => refund.php (100%) diff --git a/.gitignore b/.gitignore index 3ce83b3..9672757 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1 @@ -SEContestChatCommands.credentials.php +credentials.php diff --git a/SEContestChatCommands.php b/SEContestChatCommands.php index 55af02c..6f2b312 100644 --- a/SEContestChatCommands.php +++ b/SEContestChatCommands.php @@ -5,16 +5,16 @@ $channel = "SE channelID"; $bearer = "SE JWT token"; */ -require_once("SEContestChatCommands.credentials.php"); +require_once("credentials.php"); if (isset($_GET["key"], $_GET["action"]) && $_GET["key"] == $key) { - require_once("SEContestChatCommands.open.php"); - require_once("SEContestChatCommands.active.php"); - require_once("SEContestChatCommands.close.php"); - require_once("SEContestChatCommands.latest.php"); - require_once("SEContestChatCommands.pick.php"); - require_once("SEContestChatCommands.refund.php"); + require_once("open.php"); + require_once("active.php"); + require_once("close.php"); + require_once("latest.php"); + require_once("pick.php"); + require_once("refund.php"); switch(strtolower($_GET["action"])) { @@ -58,7 +58,7 @@ case "close": CloseContest($channel, $bearer, GetActiveId($channel, $bearer)); - break; + break; case "draw": if (isset($_GET["winner"]) && trim($_GET["winner"]) != "") @@ -79,7 +79,7 @@ case "refund": RefundContest($channel, $bearer, GetLatestId($channel, $bearer)); - break; + break; default: echo "Invalid action! Expected: start|close|draw|refund"; diff --git a/SEContestChatCommands.active.php b/active.php similarity index 100% rename from SEContestChatCommands.active.php rename to active.php diff --git a/SEContestChatCommands.close.php b/close.php similarity index 100% rename from SEContestChatCommands.close.php rename to close.php diff --git a/SEContestChatCommands.latest.php b/latest.php similarity index 100% rename from SEContestChatCommands.latest.php rename to latest.php diff --git a/SEContestChatCommands.open.php b/open.php similarity index 100% rename from SEContestChatCommands.open.php rename to open.php diff --git a/SEContestChatCommands.option.php b/option.php similarity index 100% rename from SEContestChatCommands.option.php rename to option.php diff --git a/SEContestChatCommands.pick.php b/pick.php similarity index 100% rename from SEContestChatCommands.pick.php rename to pick.php diff --git a/SEContestChatCommands.refund.php b/refund.php similarity index 100% rename from SEContestChatCommands.refund.php rename to refund.php From 4046507dbe09fadd9f281f1ce082edf85b7ae0f2 Mon Sep 17 00:00:00 2001 From: Creeperman007 Date: Mon, 9 Dec 2019 17:41:13 +0100 Subject: [PATCH 3/6] Trim for GET parameters --- SEContestChatCommands.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/SEContestChatCommands.php b/SEContestChatCommands.php index 6f2b312..bbd403a 100644 --- a/SEContestChatCommands.php +++ b/SEContestChatCommands.php @@ -19,7 +19,7 @@ switch(strtolower($_GET["action"])) { case "start": - if (isset($_GET["name"], $_GET["duration"], $_GET["options"]) && $_GET["name"] != "" && $_GET["duration"] != "" && $_GET["options"] != "") + if (isset($_GET["name"], $_GET["duration"], $_GET["options"]) && trim($_GET["name"]) != "" && trim($_GET["duration"]) != "" && trim($_GET["options"]) != "") { $duration = 10; try @@ -31,8 +31,8 @@ $duration = 15; } - $name = str_replace("_", " ", $_GET["name"]); - $optionsRaw = preg_split('/ /', $_GET["options"]); + $name = str_replace("_", " ", trim($_GET["name"])); + $optionsRaw = preg_split('/ /', trim($_GET["options"])); unset($value); $options = array(); foreach($optionsRaw as $key => $value) From e84118e336730249d0b0a2729ac95b9f286e1f8f Mon Sep 17 00:00:00 2001 From: Creeperman007 Date: Mon, 9 Dec 2019 17:42:52 +0100 Subject: [PATCH 4/6] Removed unnecessary 'unset' --- SEContestChatCommands.php | 1 - 1 file changed, 1 deletion(-) diff --git a/SEContestChatCommands.php b/SEContestChatCommands.php index bbd403a..408b04e 100644 --- a/SEContestChatCommands.php +++ b/SEContestChatCommands.php @@ -33,7 +33,6 @@ $name = str_replace("_", " ", trim($_GET["name"])); $optionsRaw = preg_split('/ /', trim($_GET["options"])); - unset($value); $options = array(); foreach($optionsRaw as $key => $value) { From abb733f83d32fa514c5494372969951a851e4b7f Mon Sep 17 00:00:00 2001 From: Creeperman007 Date: Mon, 9 Dec 2019 17:44:22 +0100 Subject: [PATCH 5/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index bb47d62..24f9a30 100644 --- a/README.md +++ b/README.md @@ -29,5 +29,5 @@ Examples are using base command `!bets` ### Request on API This will show example body of StreamElements command ``` -${customapi.example.com/SEContestChatCommands.php?key=my_key&action=${pathescape ${1}}&name=${pathescape ${2|${1}}}&duration=${pathescape ${3|${1}}}&options=${pathescape ${4:|${1}}}&winner=${pathescape ${2:|' '}}} +${customapi.example.com/SEContestChatCommands.php?key=my_key&action=${pathescape ${1}}&name=${pathescape ${2|' '}}&duration=${pathescape ${3|' '}}&options=${pathescape ${4:|' '}}&winner=${pathescape ${2:|' '}}} ``` From 4e0bd04a9360baf2c25b6ae725ac9bf16687277c Mon Sep 17 00:00:00 2001 From: Creeperman007 Date: Mon, 9 Dec 2019 17:44:57 +0100 Subject: [PATCH 6/6] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 24f9a30..616ba7c 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Chat commands for StreamElements' Contests ## Credentials -* Create file called `SEContestChatCommands.credentials.php` +* Create file called `credentials.php` * The file will contain three variables * `$key` - random string, that is used in URL * `$channel` SE Account ID that you can find [here](https://streamelements.com/dashboard/account/channels)