Implemented reply # command, allowing users to favorite specific notices by the notice id

This commit is contained in:
Craig Andrews 2009-10-27 21:48:56 -04:00
parent a1798039b2
commit 922ee7b3b2

View File

@ -124,18 +124,30 @@ class FavCommand extends Command
function execute($channel) function execute($channel)
{ {
if(substr($this->other,0,1)=='#'){
//replying to a specific notice_id
$recipient = $notice = Notice::staticGet(substr($this->other,1));
common_relative_profile($this->user, common_canonical_nickname($this->other)); if (!$notice) {
$channel->error($this->user, _('Notice with that id does not exist'));
return;
}
$recipient = $notice->getProfile();
}else{
//replying to a given user's last notice
if (!$recipient) { $recipient =
$channel->error($this->user, _('No such user.')); common_relative_profile($this->user, common_canonical_nickname($this->other));
return;
} if (!$recipient) {
$notice = $recipient->getCurrentNotice(); $channel->error($this->user, _('No such user.'));
if (!$notice) { return;
$channel->error($this->user, _('User has no last notice')); }
return; $notice = $recipient->getCurrentNotice();
if (!$notice) {
$channel->error($this->user, _('User has no last notice'));
return;
}
} }
$fave = Fave::addNew($this->user, $notice); $fave = Fave::addNew($this->user, $notice);
@ -497,6 +509,7 @@ class HelpCommand extends Command
"get <nickname> - get last notice from user\n". "get <nickname> - get last notice from user\n".
"whois <nickname> - get profile info on user\n". "whois <nickname> - get profile info on user\n".
"fav <nickname> - add user's last notice as a 'fave'\n". "fav <nickname> - add user's last notice as a 'fave'\n".
"fav #<notice_id> - add notice with the given id as a 'fave'\n".
"join <group> - join group\n". "join <group> - join group\n".
"drop <group> - leave group\n". "drop <group> - leave group\n".
"stats - get your stats\n". "stats - get your stats\n".