Commit f533ecd0 authored by MBoretto's avatar MBoretto

Merge branch 'new_command_structure_alpha' into feature/smartinterface

parents 566be6ad 24067d78
......@@ -10,20 +10,10 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Telegram;
/**
* Abstract Admin Command Class
*/
abstract class AdminCommand extends Command
{
/**
* Constructor
*
* @param Telegram $telegram
*/
public function __construct(Telegram $telegram)
{
parent::__construct($telegram);
}
}
......@@ -16,7 +16,7 @@ use Longman\TelegramBot\Entities\Update;
use Longman\TelegramBot\Entities\User;
/**
* Class Command
* Abstract Command Class
*/
abstract class Command
{
......
......@@ -10,20 +10,22 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Telegram;
/**
* Abstract System Command Class
*/
abstract class SystemCommand extends Command
{
/**
* Constructor
* A system command just executes
*
* Although system commands should just work and return 'true',
* each system command can override this method to add custom functionality.
*
* @param Telegram $telegram
* @return bool
*/
public function __construct(Telegram $telegram)
public function execute()
{
parent::__construct($telegram);
//System command, do nothing
return true;
}
}
......@@ -8,22 +8,22 @@
* file that was distributed with this source code.
*/
namespace Longman\TelegramBot\Commands\UserCommands;
namespace Longman\TelegramBot\Commands\SystemCommands;
use Longman\TelegramBot\Commands\UserCommand;
use Longman\TelegramBot\Commands\SystemCommand;
use Longman\TelegramBot\Request;
/**
* Start command
*/
class StartCommand extends UserCommand
class StartCommand extends SystemCommand
{
/**#@+
* {@inheritdoc}
*/
protected $name = 'start';
protected $description = 'Start command';
protected $usage = '/';
protected $usage = '/start';
protected $version = '1.0.1';
/**#@-*/
......
......@@ -10,20 +10,10 @@
namespace Longman\TelegramBot\Commands;
use Longman\TelegramBot\Telegram;
/**
* Abstract User Command Class
*/
abstract class UserCommand extends Command
{
/**
* Constructor
*
* @param Telegram $telegram
*/
public function __construct(Telegram $telegram)
{
parent::__construct($telegram);
}
}
......@@ -168,7 +168,7 @@ class Telegram
$this->setUploadPath(BASE_PATH . '/../Upload');
//Add default system commands path
$this->addCommandsPath(BASE_COMMANDS_PATH . '/System');
$this->addCommandsPath(BASE_COMMANDS_PATH . '/SystemCommands');
Request::initialize($this);
}
......@@ -465,10 +465,10 @@ class Telegram
//Load admin commands
if ($this->isAdmin($message->getFrom()->getId())) {
$this->addCommandsPath(BASE_COMMANDS_PATH . '/Admin', false);
$this->addCommandsPath(BASE_COMMANDS_PATH . '/AdminCommands', false);
}
$this->addCommandsPath(BASE_COMMANDS_PATH . '/User', false);
$this->addCommandsPath(BASE_COMMANDS_PATH . '/UserCommands', false);
$type = $message->getType();
if ($type === '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