Add "followers" and "following" commands

This commit is contained in:
Craig Andrews 2009-11-16 00:19:47 -05:00
parent 6470ccd1b8
commit f04dbc8fa2
2 changed files with 52 additions and 0 deletions

View File

@ -605,6 +605,44 @@ class LoginCommand extends Command
} }
} }
class FollowingCommand extends Command
{
function execute($channel)
{
$profile = $this->user->getSubscriptions(0);
$nicknames=array();
while ($profile->fetch()) {
$nicknames[]=$profile->nickname;
}
if(count($nicknames)==0){
$out=_('You are not subscribed to anyone.');
}else{
$out=_('You are subscribed to these people: ');
$out.=implode(', ',$nicknames);
}
$channel->output($this->user,$out);
}
}
class FollowersCommand extends Command
{
function execute($channel)
{
$profile = $this->user->getSubscribers();
$nicknames=array();
while ($profile->fetch()) {
$nicknames[]=$profile->nickname;
}
if(count($nicknames)==0){
$out=_('No one is subscribed to you.');
}else{
$out=_('These people are subscribed to you: ');
$out.=implode(', ',$nicknames);
}
$channel->output($this->user,$out);
}
}
class HelpCommand extends Command class HelpCommand extends Command
{ {
function execute($channel) function execute($channel)
@ -615,6 +653,8 @@ class HelpCommand extends Command
"off - turn off notifications\n". "off - turn off notifications\n".
"help - show this help\n". "help - show this help\n".
"follow <nickname> - subscribe to user\n". "follow <nickname> - subscribe to user\n".
"following - list the people you follow\n".
"followers - list the people that follow you\n".
"leave <nickname> - unsubscribe from user\n". "leave <nickname> - unsubscribe from user\n".
"d <nickname> <text> - direct message to user\n". "d <nickname> <text> - direct message to user\n".
"get <nickname> - get last notice from user\n". "get <nickname> - get last notice from user\n".

View File

@ -47,6 +47,18 @@ class CommandInterpreter
} else { } else {
return new LoginCommand($user); return new LoginCommand($user);
} }
case 'followers':
if ($arg) {
return null;
} else {
return new FollowersCommand($user);
}
case 'following':
if ($arg) {
return null;
} else {
return new FollowingCommand($user);
}
case 'on': case 'on':
if ($arg) { if ($arg) {
list($other, $extra) = $this->split_arg($arg); list($other, $extra) = $this->split_arg($arg);