From 2a2d2a0b7e823761e1ecb53ce13bf4877b6fe907 Mon Sep 17 00:00:00 2001 From: Miguel N Date: Fri, 25 Dec 2020 16:38:27 +0000 Subject: [PATCH] Added missing help command This commit adds the missing help command for the bot. --- Commandfiles/help.txt | 8 ++++++++ bot.php | 7 +++++-- src/Bot/Commands/Help.php | 41 +++++++++++++++++++++++++++++++++++++++ src/Bot/init.php | 1 + 4 files changed, 55 insertions(+), 2 deletions(-) create mode 100644 Commandfiles/help.txt mode change 100644 => 100755 bot.php create mode 100644 src/Bot/Commands/Help.php diff --git a/Commandfiles/help.txt b/Commandfiles/help.txt new file mode 100644 index 0000000..0299cc9 --- /dev/null +++ b/Commandfiles/help.txt @@ -0,0 +1,8 @@ + +:white_check_mark: Raspberry Bot Command Help :arrow_down: + +Active prefix: + +Available commands: + - numberfact [random/ (int) number] (Example: numberfact 20) + - help (This command) diff --git a/bot.php b/bot.php old mode 100644 new mode 100755 index 56e665f..01645e4 --- a/bot.php +++ b/bot.php @@ -1,9 +1,11 @@ +#!/usr/bin/env php addCommand([ new SimplePlayback, new NumberFact, - new MinecraftInfo + new MinecraftInfo, + new Help ]) ->addAction(new MessageLogger) ->setCommandPrefix($_ENV['COMMAND_PREFIX']) - ->run(); \ No newline at end of file + ->run(); diff --git a/src/Bot/Commands/Help.php b/src/Bot/Commands/Help.php new file mode 100644 index 0000000..b00ff9c --- /dev/null +++ b/src/Bot/Commands/Help.php @@ -0,0 +1,41 @@ +", $_ENV['COMMAND_PREFIX'], file_get_contents(PROJECT_ROOT . "/Commandfiles/help.txt")); + } + else + { + return ":x: There is currently no available help."; + } + + break; + + default: + return ":x: There is no help section named " . $parameters['section'] . "."; + break; + } + } +} diff --git a/src/Bot/init.php b/src/Bot/init.php index a0dc71d..c101238 100644 --- a/src/Bot/init.php +++ b/src/Bot/init.php @@ -8,3 +8,4 @@ $dotenv->load(); $dotenv->required('BOT_AUTH_TOKEN')->notEmpty(); $dotenv->required('COMMAND_PREFIX')->notEmpty(); +define('PROJECT_ROOT', realpath(__DIR__ . '/../../'));