// 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
// 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) {
break;
case 'lose':
if ($arg) {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
break;
case 'on':
if ($arg) {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
break;
case 'off':
if ($arg) {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
if (!$arg) {
$result = null;
} else {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
if (!$arg) {
$result = null;
} else {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
if (!$arg) {
$result = null;
} else {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
if (!$arg) {
$result = null;
} else {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
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 {
}
}
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 {
if (!$arg) {
$result = null;
} else {
- list($other, $extra) = $this->split_arg($arg);
+ list($other, $extra) = self::split_arg($arg);
if ($extra) {
$result = null;
} else {
}
}
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') {
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') {
$result = new TrackingCommand($user);
}
break;
- default:
- $result = false;
}
-
+
Event::handle('EndInterpretCommand', array($cmd, $arg, $user, &$result));
}
/**
* 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) {