Commit 154e33ce authored by MBoretto's avatar MBoretto

Fix Help Command Error and new commads error

parent 8d5d3435
...@@ -33,18 +33,21 @@ class HelpCommand extends Command ...@@ -33,18 +33,21 @@ class HelpCommand extends Command
$text = $message->getText(true); $text = $message->getText(true);
$commands = $this->telegram->getCommandsList(); $commands = $this->telegram->getCommandsList();
if (empty($text)) { if (empty($text)) {
$msg = 'GeoBot v. ' . $this->telegram->getVersion() . "\n\n"; $msg = 'GeoBot v. ' . $this->telegram->getVersion() . "\n\n";
$msg .= 'Commands List:' . "\n"; $msg .= 'Commands List:' . "\n";
foreach ($commands as $command) { foreach ($commands as $command) {
if (!$command->isEnabled()) { if (is_object($command)) {
continue; if (!$command->isEnabled()) {
} continue;
if (!$command->isPublic()) { }
continue; if (!$command->isPublic()) {
} continue;
}
$msg .= '/' . $command->getName() . ' - ' . $command->getDescription() . "\n"; $msg .= '/' . $command->getName() . ' - ' . $command->getDescription() . "\n";
}
} }
$msg .= "\n" . 'For exact command help type: /help <command>'; $msg .= "\n" . 'For exact command help type: /help <command>';
......
...@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request; ...@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command; use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
class LeftChatParticipantCommand extends Command class LeftchatparticipantCommand extends Command
{ {
protected $name = 'left_chat_participant'; protected $name = 'left_chat_participant';
protected $description = 'Left Chat Participant'; protected $description = 'Left Chat Participant';
......
...@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request; ...@@ -14,7 +14,7 @@ use Longman\TelegramBot\Request;
use Longman\TelegramBot\Command; use Longman\TelegramBot\Command;
use Longman\TelegramBot\Entities\Update; use Longman\TelegramBot\Entities\Update;
class NewChatParticipantCommand extends Command class Newchatparticipantcommand extends Command
{ {
protected $name = 'new_chat_participant'; protected $name = 'new_chat_participant';
protected $description = 'New Chat Participant'; protected $description = 'New Chat Participant';
......
...@@ -189,8 +189,11 @@ class Telegram ...@@ -189,8 +189,11 @@ class Telegram
continue; continue;
} }
$name = $fileInfo->getFilename(); $name = $fileInfo->getFilename();
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name); if (substr($name, -11, 11) === 'Command.php') {
$name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
}
} }
if (!empty($this->commands_dir)) { if (!empty($this->commands_dir)) {
...@@ -204,12 +207,13 @@ class Telegram ...@@ -204,12 +207,13 @@ class Telegram
continue; continue;
} }
$name = $fileInfo->getFilename(); $name = $fileInfo->getFilename();
$name = strtolower(str_replace('Command.php', '', $name)); if (substr($name, -11, 11) === 'Command.php') {
$commands[$name] = $this->getCommandClass($name); $name = strtolower(str_replace('Command.php', '', $name));
$commands[$name] = $this->getCommandClass($name);
}
} }
} }
} }
return $commands; return $commands;
} }
......
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