X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=lib%2Fcommandinterpreter.php;h=fbc6174bbfab1b95a2d9573df2043e3688cf9a0f;hb=c89ed16d24d56879bf40a70d500509d1d42a4532;hp=6babcba4f5c71b5cdb5f6de1afa083f02f794bdb;hpb=be5d113fc684fcbe41b8374c62bfeb0f267216b7;p=quix0rs-gnu-social.git diff --git a/lib/commandinterpreter.php b/lib/commandinterpreter.php index 6babcba4f5..fbc6174bbf 100644 --- a/lib/commandinterpreter.php +++ b/lib/commandinterpreter.php @@ -17,7 +17,7 @@ * along with this program. If not, see . */ -if (!defined('STATUSNET')) { exit(1); } +if (!defined('STATUSNET') && !defined('LACONICA')) { exit(1); } require_once INSTALLDIR.'/lib/command.php'; @@ -28,7 +28,7 @@ class CommandInterpreter # XXX: localise $text = preg_replace('/\s+/', ' ', trim($text)); - list($cmd, $arg) = explode(' ', $text, 2); + list($cmd, $arg) = $this->split_arg($text); # We try to support all the same commands as Twitter, see # http://getsatisfaction.com/twitter/topics/what_are_the_twitter_commands @@ -41,9 +41,44 @@ class CommandInterpreter return null; } return new HelpCommand($user); + case 'login': + if ($arg) { + return null; + } else { + return new LoginCommand($user); + } + case 'lose': + if ($arg) { + list($other, $extra) = $this->split_arg($arg); + if ($extra) { + return null; + } else { + return new LoseCommand($user, $other); + } + } else { + return null; + } + case 'subscribers': + if ($arg) { + return null; + } else { + return new SubscribersCommand($user); + } + case 'subscriptions': + if ($arg) { + return null; + } else { + return new SubscriptionsCommand($user); + } + case 'groups': + if ($arg) { + return null; + } else { + return new GroupsCommand($user); + } case 'on': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -54,7 +89,7 @@ class CommandInterpreter } case 'off': if ($arg) { - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -70,12 +105,32 @@ class CommandInterpreter } else { return new OffCommand($user); } + case 'join': + if (!$arg) { + return null; + } + list($other, $extra) = $this->split_arg($arg); + if ($extra) { + return null; + } else { + return new JoinCommand($user, $other); + } + case 'drop': + if (!$arg) { + return null; + } + list($other, $extra) = $this->split_arg($arg); + if ($extra) { + return null; + } else { + return new DropCommand($user, $other); + } case 'follow': case 'sub': if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -86,7 +141,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -97,7 +152,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -108,17 +163,41 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if (!$extra) { return null; } else { return new MessageCommand($user, $other, $extra); } + case 'r': + case 'reply': + if (!$arg) { + return null; + } + list($other, $extra) = $this->split_arg($arg); + if (!$extra) { + return null; + } else { + return new ReplyCommand($user, $other, $extra); + } + case 'repeat': + case 'rp': + case 'rt': + case 'rd': + if (!$arg) { + return null; + } + list($other, $extra) = $this->split_arg($arg); + if ($extra) { + return null; + } else { + return new RepeatCommand($user, $other); + } case 'whois': if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -128,7 +207,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -138,7 +217,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -153,7 +232,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($other, $extra) = explode(' ', $arg, 2); + list($other, $extra) = $this->split_arg($arg); if ($extra) { return null; } else { @@ -163,7 +242,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'off') { @@ -175,7 +254,7 @@ class CommandInterpreter if (!$arg) { return null; } - list($word, $extra) = explode(' ', $arg, 2); + list($word, $extra) = $this->split_arg($arg); if ($extra) { return null; } else if ($word == 'all') { @@ -193,5 +272,17 @@ class CommandInterpreter return false; } } + + /** + * Split arguments without triggering a PHP notice warning + */ + function split_arg($text) + { + $pieces = explode(' ', $text, 2); + if (count($pieces) == 1) { + $pieces[] = null; + } + return $pieces; + } }