Commit 8d5d3435 authored by MBoretto's avatar MBoretto

Fixed namespace bug for external commands

parent f83b2b2e
...@@ -405,14 +405,15 @@ class Telegram ...@@ -405,14 +405,15 @@ class Telegram
$command = $this->sanitizeCommand($command); $command = $this->sanitizeCommand($command);
$class_name = ucfirst($command) . 'Command'; $class_name = ucfirst($command) . 'Command';
$class_name_space = __NAMESPACE__ . '\\Commands\\' . $class_name;
foreach ($this->commands_dir as $dir) { foreach ($this->commands_dir as $dir) {
if (is_file($dir . '/' . $class_name . '.php')) { if (is_file($dir . '/' . $class_name . '.php')) {
require_once($dir . '/' . $class_name . '.php'); require_once($dir . '/' . $class_name . '.php');
if (!class_exists($class_name)) { if (!class_exists($class_name_space)) {
continue; continue;
} }
$class = new $class_name($this); $class = new $class_name_space($this);
if (!empty($update)) { if (!empty($update)) {
$class->setUpdate($update); $class->setUpdate($update);
...@@ -422,9 +423,8 @@ class Telegram ...@@ -422,9 +423,8 @@ class Telegram
} }
} }
$class_name = __NAMESPACE__ . '\\Commands\\' . $class_name; if (class_exists($class_name_space)) {
if (class_exists($class_name)) { $class = new $class_name_space($this);
$class = new $class_name($this);
if (!empty($update)) { if (!empty($update)) {
$class->setUpdate($update); $class->setUpdate($update);
} }
......
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