From 999fed8bc348db9b0414a80d2017394d90977b13 Mon Sep 17 00:00:00 2001 From: wright Date: Sat, 30 Oct 2021 00:10:17 +0800 Subject: [PATCH 1/2] feat: add resetCommandsPaths Solve the problem that the default command cannot be removed --- src/Telegram.php | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/Telegram.php b/src/Telegram.php index a36cab9a..7b7f4600 100644 --- a/src/Telegram.php +++ b/src/Telegram.php @@ -854,6 +854,24 @@ public function addCommandsPath(string $path, bool $before = true): Telegram return $this; } + /** + * change Command folder path (other command folder about to invalid) + * + * @param string $path Custom commands path + * @author Wright + * @return Telegram + */ + public function resetCommandsPaths(string $path): Telegram + { + if (!is_dir($path)) { + TelegramLog::error('reset commands path "' . $path . '" does not exist.'); + } elseif (!in_array($path, $this->commands_paths, true)) { + $this->commands_paths = $path; + } + + return $this; + } + /** * Add multiple custom commands paths * From 3a1737b58c083d8a180462c0ebb829d123338ced Mon Sep 17 00:00:00 2001 From: wright Date: Sat, 30 Oct 2021 00:16:43 +0800 Subject: [PATCH 2/2] feat: add resetCommandsPaths --- src/Telegram.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Telegram.php b/src/Telegram.php index 7b7f4600..c5bad748 100644 --- a/src/Telegram.php +++ b/src/Telegram.php @@ -866,7 +866,7 @@ public function resetCommandsPaths(string $path): Telegram if (!is_dir($path)) { TelegramLog::error('reset commands path "' . $path . '" does not exist.'); } elseif (!in_array($path, $this->commands_paths, true)) { - $this->commands_paths = $path; + $this->commands_paths = [$path]; } return $this;