diff --git a/file/lib/system/chat/commands/CommandHandler.class.php b/file/lib/system/chat/commands/CommandHandler.class.php index 2121fc2..23335fa 100644 --- a/file/lib/system/chat/commands/CommandHandler.class.php +++ b/file/lib/system/chat/commands/CommandHandler.class.php @@ -11,9 +11,9 @@ * @package timwolla.wcf.chat * @subpackage system.chat.commands */ -class CommandHandler { +final class CommandHandler { const COMMAND_CHAR = '/'; - public $text = ''; + private $text = ''; /** * Initialises the CommandHandler @@ -32,6 +32,15 @@ public function isCommand($text = null) { return StringUtil::substring($text, 0, StringUtil::length(static::COMMAND_CHAR)) == static::COMMAND_CHAR; } + /** + * Returns the whole message. + * + * @return string + */ + public function getText() { + return $this->text; + } + /** * Returns the parameter-string. * @@ -40,6 +49,7 @@ public function isCommand($text = null) { public function getParameters() { $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); + if (!isset($parts[1])) return ''; return $parts[1]; } @@ -50,7 +60,7 @@ public function loadCommand() { $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); if ($this->isCommand($parts[0])) { - return new commands\commands\PlainCommand($this); + return new commands\Plain($this); } $class = '\wcf\system\chat\commands\commands\\'.ucfirst($parts[0]); diff --git a/file/lib/system/chat/commands/commands/Plain.class.php b/file/lib/system/chat/commands/commands/Plain.class.php new file mode 100644 index 0000000..e0d9e53 --- /dev/null +++ b/file/lib/system/chat/commands/commands/Plain.class.php @@ -0,0 +1,36 @@ + + * @package timwolla.wcf.chat + * @subpackage system.chat.commands.commands + */ +class Plain extends \wcf\system\chat\commands\AbstractCommand { + public $enableSmilies = \wcf\system\chat\commands\ICommand::SMILEY_USER; + + /** + * @see \wcf\system\chat\commands\ICommand::getType() + */ + public function getType() { + return \wcf\data\chat\message\ChatMessage::TYPE_NORMAL; + } + + /** + * @see \wcf\system\chat\commands\ICommand::getMessage() + */ + public function getMessage() { + return \wcf\util\StringUtil::substring($this->commandHandler->getText(), 1); + } + + /** + * @see \wcf\system\chat\commands\ICommand::getReceiver() + */ + public function getReceiver() { + return null; + } +}