X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommandinterpreter.php;h=e7d98da0255048b9786acc8506f72620f1a3aba2;hb=e8d1bb25469fe1ef0cbcb32c3022010997aca4b0;hp=6b1b70055e06c5c9ed29b87acd075009fb450deb;hpb=cd4b23aa399a51744787e580f8dfdb3886bfc8f5;p=quix0rs-gnu-social.git diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 6b1b70055e..e7d98da025 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -28,7 +28,7 @@ class CommandInterpreter // XXX: localise $text = preg_replace('/\s+/', ' ', trim($text)); - list($cmd, $arg) = $this->split_arg($text); + list($cmd, $arg) = self::split_arg($text); // We try to support all the same commands as Twitter, see // http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands @@ -37,7 +37,7 @@ class CommandInterpreter $cmd = strtolower($cmd); - if (Event::handle('StartIntepretCommand', array($cmd, $arg, $user, &$result))) { + if (Event::handle('StartInterpretCommand', array($cmd, $arg, $user, &$result))) { switch($cmd) { case 'help': if ($arg) { @@ -55,7 +55,7 @@ class CommandInterpreter break; case 'lose': if ($arg) { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -88,7 +88,7 @@ class CommandInterpreter break; case 'on': if ($arg) { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -100,7 +100,7 @@ class CommandInterpreter break; case 'off': if ($arg) { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -122,7 +122,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -134,7 +134,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -147,7 +147,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -160,7 +160,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -173,31 +173,19 @@ class CommandInterpreter if (!$arg) { $result = null; } - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { $result = new GetCommand($user, $other); } break; - case 'd': - case 'dm': - if (!$arg) { - $result = null; - } - list($other, $extra) = $this->split_arg($arg); - if (!$extra) { - $result = null; - } else { - $result = new MessageCommand($user, $other, $extra); - } - break; case 'r': case 'reply': if (!$arg) { $result = null; } - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if (!$extra) { $result = null; } else { @@ -211,7 +199,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -223,7 +211,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -231,23 +219,11 @@ class CommandInterpreter } } break; - case 'fav': - if (!$arg) { - $result = null; - } else { - list($other, $extra) = $this->split_arg($arg); - if ($extra) { - $result = null; - } else { - $result = new FavCommand($user, $other); - } - } - break; case 'nudge': if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -266,7 +242,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($other, $extra) = $this->split_arg($arg); + list($other, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else { @@ -274,11 +250,37 @@ class CommandInterpreter } } break; + case 'list': + case 'tag': + if (!$arg) { + $result = null; + break; + } + list($other, $tags) = self::split_arg($arg); + if (!$tags) { + $result = null; + } else { + $result = new TagCommand($user, $other, $tags); + } + break; + case 'unlist': + case 'untag': + if (!$arg) { + $result = null; + break; + } + list($other, $tags) = self::split_arg($arg); + if (!$tags) { + $result = null; + } else { + $result = new UntagCommand($user, $other, $tags); + } + break; case 'track': if (!$arg) { $result = null; } else { - list($word, $extra) = $this->split_arg($arg); + list($word, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else if ($word == 'off') { @@ -292,7 +294,7 @@ class CommandInterpreter if (!$arg) { $result = null; } else { - list($word, $extra) = $this->split_arg($arg); + list($word, $extra) = self::split_arg($arg); if ($extra) { $result = null; } else if ($word == 'all') { @@ -313,7 +315,7 @@ class CommandInterpreter default: $result = false; } - + Event::handle('EndInterpretCommand', array($cmd, $arg, $user, &$result)); } @@ -323,7 +325,7 @@ class CommandInterpreter /** * Split arguments without triggering a PHP notice warning */ - function split_arg($text) + static function split_arg($text) { $pieces = explode(' ', $text, 2); if (count($pieces) == 1) {