Skip to content
This repository has been archived by the owner on Apr 22, 2021. It is now read-only.

Commit

Permalink
Add --me for timeline to just personal tweets
Browse files Browse the repository at this point in the history
  • Loading branch information
mdom committed Mar 2, 2016
1 parent ec9ac0b commit 5009c89
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/App/txtnix.pm
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ sub get_tweets {
if $self->use_cache;
}

return $self->filter_tweets(@tweets);
return @tweets;
}

sub filter_tweets {
Expand Down
5 changes: 5 additions & 0 deletions lib/App/txtnix/Cmd.pm
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ opt until => (
comment => 'Only display tweets written until the supplied datetime.',
alias => 'u',
);
opt me => (
isa => 'Bool',
comment => 'Only display your tweets and all replies and mentions.',
alias => 'm',
);

subcmd
cmd => 'view',
Expand Down
10 changes: 10 additions & 0 deletions lib/App/txtnix/Cmd/timeline.pm
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
package App::txtnix::Cmd::timeline;
use Mojo::Base 'App::txtnix';

has 'me' => sub { 0 };

sub run {
my $self = shift;
my @tweets = $self->get_tweets();
my $url = $self->twturl;

if ( $self->me ) {
@tweets =
grep { $_->source->file || $_->text =~ /\@<(?:\w+ )?$url>/o } @tweets;
}

@tweets = $self->filter_tweets(@tweets);
$self->display_tweets( 1, @tweets );
return 0;
}
Expand Down
1 change: 1 addition & 0 deletions lib/App/txtnix/Cmd/view.pm
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ sub run {
? $self->following->{ $self->source }
: $self->source;
my @tweets = $self->get_tweets($url);
@tweets = $self->filter_tweets(@tweets);
$self->display_tweets( 0, @tweets );
return 0;
}
Expand Down

0 comments on commit 5009c89

Please sign in to comment.