diff --git a/file/lib/page/ChatPage.class.php b/file/lib/page/ChatPage.class.php index e55376d..e5ed79e 100644 --- a/file/lib/page/ChatPage.class.php +++ b/file/lib/page/ChatPage.class.php @@ -146,6 +146,9 @@ public function readCommands() { if ($command == 'Plain') continue; $this->commands[] = \wcf\util\StringUtil::toLowerCase($command); } + + $this->commands = array_merge($this->commands, array_keys(\chat\system\command\CommandHandler::getAliasMap())); + sort($this->commands); } /** diff --git a/file/lib/system/command/CommandHandler.class.php b/file/lib/system/command/CommandHandler.class.php index d8a60c6..bf3607c 100644 --- a/file/lib/system/command/CommandHandler.class.php +++ b/file/lib/system/command/CommandHandler.class.php @@ -14,19 +14,19 @@ final class CommandHandler { /** * char that indicates a command - * @var string + * @var string */ const COMMAND_CHAR = '/'; /** * message text - * @var string + * @var string */ private $text = ''; /** * current room - * @var \chat\data\room\Room + * @var \chat\data\room\Room */ private $room = null; @@ -41,6 +41,22 @@ public function __construct($text, \chat\data\room\Room $room = null) { $this->room = $room; } + /** + * Returns the alias map. Key is the alias, value is the target. + * + * @return array + */ + public static function getAliasMap() { + $result = array(); + foreach (explode("\n", StringUtil::unifyNewlines(StringUtil::toLowerCase(CHAT_COMMAND_ALIASES))) as $line) { + list($key, $val) = explode(':', $line, 2); + + $result[$key] = $val; + } + + return $result; + } + /** * Checks whether the given text is a command. */ @@ -90,6 +106,9 @@ public function loadCommand() { return new commands\PlainCommand($this); } + $aliases = self::getAliasMap(); + if (isset($aliases[$parts[0]])) $parts[0] = $aliases[$parts[0]]; + $class = '\chat\system\command\commands\\'.ucfirst(strtolower($parts[0])).'Command'; if (!class_exists($class)) { throw new NotFoundException(); diff --git a/option.xml b/option.xml index 29a6eff..bef3647 100644 --- a/option.xml +++ b/option.xml @@ -44,10 +44,12 @@ 1 5000 - diff --git a/package.xml b/package.xml index d6c16fa..d6f9f46 100644 --- a/package.xml +++ b/package.xml @@ -5,7 +5,7 @@ 1 - 3.0.0 Alpha 56 + 3.0.0 Alpha 58 2011-11-26 ]]>