Commit 7d6b6d32 authored by Avtandil Kikabidze's avatar Avtandil Kikabidze

Fixed array style

parent 2822ba5f
...@@ -13,8 +13,14 @@ namespace Longman\TelegramBot; ...@@ -13,8 +13,14 @@ namespace Longman\TelegramBot;
define('BASE_PATH', __DIR__); define('BASE_PATH', __DIR__);
define('BASE_COMMANDS_PATH', BASE_PATH . '/Commands'); define('BASE_COMMANDS_PATH', BASE_PATH . '/Commands');
use Exception;
use Longman\TelegramBot\Commands\Command;
use Longman\TelegramBot\Entities\ServerResponse;
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Exception\TelegramException; use Longman\TelegramBot\Exception\TelegramException;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use RegexIterator;
class Telegram class Telegram
{ {
...@@ -189,9 +195,9 @@ class Telegram ...@@ -189,9 +195,9 @@ class Telegram
foreach ($this->commands_paths as $path) { 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($path) new RecursiveDirectoryIterator($path)
), ),
'/^.+Command.php$/' '/^.+Command.php$/'
); );
...@@ -208,11 +214,11 @@ class Telegram ...@@ -208,11 +214,11 @@ class Telegram
require_once $file->getPathname(); require_once $file->getPathname();
$command_obj = $this->getCommandObject($command); $command_obj = $this->getCommandObject($command);
if ($command_obj instanceof Commands\Command) { if ($command_obj instanceof Command) {
$commands[$command_name] = $command_obj; $commands[$command_name] = $command_obj;
} }
} }
} catch (\Exception $e) { } catch (Exception $e) {
throw new TelegramException('Error getting commands from path: ' . $path); throw new TelegramException('Error getting commands from path: ' . $path);
} }
} }
...@@ -287,10 +293,13 @@ class Telegram ...@@ -287,10 +293,13 @@ class Telegram
public function handleGetUpdates($limit = null, $timeout = null) public function handleGetUpdates($limit = null, $timeout = null)
{ {
if (!DB::isDbConnected()) { if (!DB::isDbConnected()) {
return new Entities\ServerResponse([ return new ServerResponse(
'ok' => false, [
'description' => 'getUpdates needs MySQL connection!', 'ok' => false,
], $this->bot_name); 'description' => 'getUpdates needs MySQL connection!',
],
$this->bot_name
);
} }
//DB Query //DB Query
...@@ -307,7 +316,7 @@ class Telegram ...@@ -307,7 +316,7 @@ class Telegram
if ($response->isOk()) { if ($response->isOk()) {
//Process all updates //Process all updates
foreach ((array) $response->getResult() as $result) { foreach ((array)$response->getResult() as $result) {
$this->processUpdate($result); $this->processUpdate($result);
} }
} }
......
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