mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-12-22 21:40:08 +00:00
Make commands more flexible
Now aliases like “toRoot:whisper root,” are possible.
This commit is contained in:
parent
098f048e29
commit
8ccefdb971
@ -39,6 +39,11 @@ final class CommandHandler {
|
||||
public function __construct($text, \chat\data\room\Room $room = null) {
|
||||
$this->text = $text;
|
||||
$this->room = $room;
|
||||
|
||||
$aliases = self::getAliasMap();
|
||||
foreach ($aliases as $search => $replace) {
|
||||
$this->text = \wcf\system\Regex::compile('^'.preg_quote($search))->replace($this->text, $replace);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@ -106,9 +111,6 @@ 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();
|
||||
|
Loading…
Reference in New Issue
Block a user