From 6046e40cc2240400fde320a52ef36e2c7a3023c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20D=C3=BCsterhus?= Date: Tue, 27 Dec 2011 14:32:28 +0100 Subject: [PATCH] Adding /me --- .../chat/commands/CommandHandler.class.php | 11 +++++++ .../chat/commands/commands/Free.class.php | 13 ++++---- .../chat/commands/commands/Me.class.php | 30 +++++++++++++++++++ 3 files changed, 47 insertions(+), 7 deletions(-) create mode 100644 file/lib/system/chat/commands/commands/Me.class.php diff --git a/file/lib/system/chat/commands/CommandHandler.class.php b/file/lib/system/chat/commands/CommandHandler.class.php index 56271d5..a0b5406 100644 --- a/file/lib/system/chat/commands/CommandHandler.class.php +++ b/file/lib/system/chat/commands/CommandHandler.class.php @@ -32,6 +32,17 @@ public function isCommand($text = null) { return StringUtil::substring($text, 0, StringUtil::length(static::COMMAND_CHAR)) == static::COMMAND_CHAR; } + /** + * Returns the parameter-string. + * + * @return string + */ + public function getParameters() { + $parts = explode(' ', StringUtil::substring($this->text, StringUtil::length(static::COMMAND_CHAR)), 2); + + return $parts[1]; + } + /** * Loads the command. */ diff --git a/file/lib/system/chat/commands/commands/Free.class.php b/file/lib/system/chat/commands/commands/Free.class.php index a6bfdfe..4ed581c 100644 --- a/file/lib/system/chat/commands/commands/Free.class.php +++ b/file/lib/system/chat/commands/commands/Free.class.php @@ -10,14 +10,13 @@ * @package timwolla.wcf.chat * @subpackage system.chat.commands.commands */ -class Free extends \wcf\system\chat\commands\AbstractCommand { - const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_USER; - - public function getType() { - return \wcf\data\chat\message\ChatMessage::TYPE_ME; - } +class Free extends Me { + const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_OFF; + /** + * @see \wcf\system\chat\commands\ICommand::getMessage() + */ public function getMessage() { - return 'freed the fish'; + return 'freed the fish. OH A NOEZ'; } } diff --git a/file/lib/system/chat/commands/commands/Me.class.php b/file/lib/system/chat/commands/commands/Me.class.php new file mode 100644 index 0000000..c0e79c8 --- /dev/null +++ b/file/lib/system/chat/commands/commands/Me.class.php @@ -0,0 +1,30 @@ + + * @package timwolla.wcf.chat + * @subpackage system.chat.commands.commands + */ +class Me extends \wcf\system\chat\commands\AbstractCommand { + const ENABLE_SMILIES = \wcf\system\chat\commands\ICommand::SMILEY_USER; + + /** + * @see \wcf\system\chat\commands\ICommand::getType() + */ + public function getType() { + return \wcf\data\chat\message\ChatMessage::TYPE_ME; + } + + /** + * @see \wcf\system\chat\commands\ICommand::getMessage() + */ + public function getMessage() { + return$this->commandHandler->getParameters(); + } +}