X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommandinterpreter.php;h=c546cf0fca94ca34f500a804ad34868981f93f83;hb=3d334451c45bd93b222d58155404786ee0667a0e;hp=d1574c55fda95dca5bd4ef01abe62f9899351cbf;hpb=87d46e1ae5e5effcc985021ff5af3f10815f3d3c;p=quix0rs-gnu-social.git diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index d1574c55fd..c546cf0fca 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 @@ -36,8 +36,9 @@ class CommandInterpreter // StatusNet $cmd = strtolower($cmd); + $result = false; - 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 +56,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 +89,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 +101,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 +123,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 +135,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 +148,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 +161,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,57 +174,30 @@ 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 { $result = new ReplyCommand($user, $other, $extra); } break; - case 'repeat': - case 'rp': - case 'rt': - case 'rd': - if (!$arg) { - $result = null; - } else { - list($other, $extra) = $this->split_arg($arg); - if ($extra) { - $result = null; - } else { - $result = new RepeatCommand($user, $other); - } - } - break; case 'whois': 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 +205,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 +228,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 { @@ -280,7 +242,7 @@ class CommandInterpreter $result = null; break; } - list($other, $tags) = $this->split_arg($arg); + list($other, $tags) = self::split_arg($arg); if (!$tags) { $result = null; } else { @@ -293,7 +255,7 @@ class CommandInterpreter $result = null; break; } - list($other, $tags) = $this->split_arg($arg); + list($other, $tags) = self::split_arg($arg); if (!$tags) { $result = null; } else { @@ -304,7 +266,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 == 'off') { @@ -318,7 +280,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') { @@ -336,8 +298,6 @@ class CommandInterpreter $result = new TrackingCommand($user); } break; - default: - $result = false; } Event::handle('EndInterpretCommand', array($cmd, $arg, $user, &$result)); @@ -349,7 +309,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) {