Commit b65d7da7 authored by Armando Lüscher's avatar Armando Lüscher

Rename all "path" related variables and documentation.

Correct and complete a few docblocks.
parent 485743d8
...@@ -54,11 +54,11 @@ class Telegram ...@@ -54,11 +54,11 @@ class Telegram
protected $input; protected $input;
/** /**
* Custom commands folder * Custom commands paths
* *
* @var array * @var array
*/ */
protected $commands_dir = []; protected $commands_paths = [];
/** /**
* Row custom update (json) * Row custom update (json)
...@@ -163,7 +163,7 @@ class Telegram ...@@ -163,7 +163,7 @@ class Telegram
$this->api_key = $api_key; $this->api_key = $api_key;
$this->bot_name = $bot_name; $this->bot_name = $bot_name;
//Set default download and upload dir //Set default download and upload path
$this->setDownloadPath(BASE_PATH . '/../Download'); $this->setDownloadPath(BASE_PATH . '/../Download');
$this->setUploadPath(BASE_PATH . '/../Upload'); $this->setUploadPath(BASE_PATH . '/../Upload');
...@@ -194,12 +194,12 @@ class Telegram ...@@ -194,12 +194,12 @@ class Telegram
{ {
$commands = []; $commands = [];
foreach ($this->commands_dir as $dir) { foreach ($this->commands_paths as $path) {
try { try {
//Get all "*Command.php" files //Get all "*Command.php" files
$files = new \RegexIterator( $files = new \RegexIterator(
new \RecursiveIteratorIterator( new \RecursiveIteratorIterator(
new \RecursiveDirectoryIterator($dir) new \RecursiveDirectoryIterator($path)
), ),
'/^.+Command.php$/' '/^.+Command.php$/'
); );
...@@ -251,7 +251,7 @@ class Telegram ...@@ -251,7 +251,7 @@ class Telegram
} }
*/ */
} catch (\Exception $e) { } catch (\Exception $e) {
throw new TelegramException('Error getting commands from path: ' . $dir); throw new TelegramException('Error getting commands from path: ' . $path);
} }
} }
...@@ -508,7 +508,7 @@ class Telegram ...@@ -508,7 +508,7 @@ class Telegram
* Execute /command * Execute /command
* *
* @param string $command * @param string $command
* @param \Longman\TelegramBot\Entities\ServerResponse $update * @param \Longman\TelegramBot\Entities\Update $update
* *
* @return mixed * @return mixed
*/ */
...@@ -597,20 +597,21 @@ class Telegram ...@@ -597,20 +597,21 @@ class Telegram
/** /**
* Add custom commands path * Add custom commands path
* *
* @param string $folder Custom commands path * @param string $path Custom commands path
* @param bool $before If the path should be prepended or appended to the list
* *
* @return \Longman\TelegramBot\Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function addCommandsPath($folder, $before = true) public function addCommandsPath($path, $before = true)
{ {
if (!is_dir($folder)) { if (!is_dir($path)) {
throw new TelegramException('Commands folder "' . $folder . '" does not exist!'); throw new TelegramException('Commands path "' . $path . '" does not exist!');
} }
if (!in_array($folder, $this->commands_dir)) { if (!in_array($path, $this->commands_paths)) {
if ($before) { if ($before) {
array_unshift($this->commands_dir, $folder); array_unshift($this->commands_paths, $path);
} else { } else {
array_push($this->commands_dir, $folder); array_push($this->commands_paths, $path);
} }
} }
return $this; return $this;
...@@ -619,13 +620,13 @@ class Telegram ...@@ -619,13 +620,13 @@ class Telegram
/** /**
* Set custom upload path * Set custom upload path
* *
* @param string $folder Custom upload path * @param string $path Custom upload path
* *
* @return \Longman\TelegramBot\Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function setUploadPath($folder) public function setUploadPath($path)
{ {
$this->upload_path = $folder; $this->upload_path = $path;
return $this; return $this;
} }
...@@ -642,13 +643,13 @@ class Telegram ...@@ -642,13 +643,13 @@ class Telegram
/** /**
* Set custom download path * Set custom download path
* *
* @param string $folder Custom download path * @param string $path Custom download path
* *
* @return \Longman\TelegramBot\Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function setDownloadPath($folder) public function setDownloadPath($path)
{ {
$this->download_path = $folder; $this->download_path = $path;
return $this; return $this;
} }
...@@ -669,15 +670,14 @@ class Telegram ...@@ -669,15 +670,14 @@ class Telegram
* For example you can add the channel name at the command /sendtochannel * For example you can add the channel name at the command /sendtochannel
* Or you can add the api key for external service. * Or you can add the api key for external service.
* *
*
* @param string $command * @param string $command
* @param array $array * @param array $config
* *
* @return \Longman\TelegramBot\Telegram * @return \Longman\TelegramBot\Telegram
*/ */
public function setCommandConfig($command, array $array) public function setCommandConfig($command, array $config)
{ {
$this->commands_config[$command] = $array; $this->commands_config[$command] = $config;
return $this; return $this;
} }
...@@ -686,7 +686,7 @@ class Telegram ...@@ -686,7 +686,7 @@ class Telegram
* *
* @param string $command * @param string $command
* *
* @return object * @return array
*/ */
public function getCommandConfig($command) public function getCommandConfig($command)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment