App-bsky

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

Revision history for Perl extension App-bsky

0.04 2024-02-13T21:36:16Z

    - Update to fit current API of At.pm

0.03 2024-01-27T23:46:20Z

    - Commands for app passwords, likes, reposts, invite codes, threads, etc.

0.02 2024-01-26T19:00:52Z

    - Less broken session management

0.01 2024-01-26T03:45:10Z

    - original version

README.md  view on Meta::CPAN

```

Display posts from timeline.

### Options

```
--json      boolean flag; content is printed as JSON objects if given
```

## thread

```
thread at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w
```

Show a thread.

### Options

```
--json      boolean flag; content is printed as JSON objects if given
-n   value  number of items
```

## post

lib/App/bsky.pm  view on Meta::CPAN

            }
            else {
                $self->say( 'DID: ' . $session->{did}->_raw );
                $self->say( 'Email: ' . $session->{email} );
                $self->say( 'Handle: ' . $session->{handle}->_raw );
            }
            return 1;
        }

        method _dump_post ( $depth, $post ) {
            if ( $post->isa('At::Lexicon::app::bsky::feed::threadViewPost') && builtin::blessed $post->parent ) {
                $self->_dump_post( $depth++, $post->parent );
                $post = $post->post;
            }
            elsif ( $post->isa('At::Lexicon::app::bsky::feed::threadViewPost') ) {
                $self->_dump_post( $depth++, $post->post );
                my $replies = $post->replies // [];
                $self->_dump_post( $depth + 2, $_->post ) for @$replies;
                return;
            }

            #~ warn ref $post;
            #~ use Data::Dump;
            #~ ddx $post->_raw;
            # TODO: Support image embeds as raw links

lib/App/bsky.pm  view on Meta::CPAN

            scalar @{ $tl->{feed} };
        }
        method cmd_tl (@args) { $self->cmd_timeline(@args); }

        method cmd_stream() {

            # Mojo::UserAgent is triggering 'Subroutine attributes must come before the signature' bug in perl 5.38.x
            return $self->err('Streaming client requires Mojo::UserAgent') unless $Mojo::UserAgent::VERSION;
        }

        method cmd_thread (@args) {
            GetOptionsFromArray( \@args, 'json!' => \my $json, 'n=i' => \my $number );
            $number //= ();
            my ($id) = @args;
            $id // return $self->cmd_help('thread');
            my $res = $bsky->feed_getPostThread( uri => $id, depth => $number, parentHeight => $number );    # $uri, depth, $parentHeight
            return unless $res->{thread} && builtin::blessed $res->{thread};
            return $self->say( JSON::Tiny::to_json $res->{thread}->_raw ) if $json;
            $self->_dump_post( 0, $res->{thread} );
        }

        method cmd_post ($text) {
            my $res = $bsky->post( text => $text );
            defined $res->{uri} ? $self->say( $res->{uri} ) : 0;
        }

        method cmd_delete ($rkey) {
            $bsky->delete($rkey);
        }

script/bsky  view on Meta::CPAN


    # shorthand:
    bsky tl

Display posts from timeline.

=head3 Options

    --json      boolean flag; content is printed as JSON objects if given

=head2 thread

    thread at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w

Show a thread.

=head3 Options

    --json      boolean flag; content is printed as JSON objects if given
    -n   value  number of items

=head2 post

    post "This is a test"

t/00_compile.t  view on Meta::CPAN

use App::bsky;
#
my $temp = Path::Tiny->tempfile('.bsky.XXXXX');
isa_ok my $cli = App::bsky::CLI->new( config_file => $temp ), ['App::bsky::CLI'];
subtest 'commands' => sub {
    can_ok $cli, $_ for sort qw[
        cmd_showprofile cmd_updateprofile
        cmd_showsession
        cmd_timeline    cmd_tl
        cmd_stream
        cmd_thread
        cmd_post    cmd_delete
        cmd_like    cmd_unlike      cmd_likes
        cmd_repost  cmd_reposts
        cmd_follow  cmd_unfollow    cmd_follows cmd_followers
        cmd_block   cmd_unblock     cmd_blocks
        cmd_login
        cmd_notifications   cmd_notif
        cmd_invitecodes
        cmd_listapppasswords    cmd_addapppassword  cmd_revokeapppassword
        cmd_config

t/01_client.t  view on Meta::CPAN

            sleep 1;
            ok client->run( 'like', $uri ), 'like at://...';
            sleep 1;
            like my $repost = is_say { client->run( 'repost', $uri ) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.repost],
                'repost at://';
            sleep 1;
            like is_say { client->run( 'reposts', $uri, '--json' ) }, qr[atperl.bsky.social], 'reposts at://... --json';
            ok client->run( 'delete', $repost ), 'delete at://... [delete repost]';
            ok client->run( 'delete', $uri ),    'delete at://... [delete post]';
        };
        like is_say { client->run(qw[thread at://did:plc:qdvyf5jhuxqx667ay7k7nagl/app.bsky.feed.post/3kju327qezs2n]) },
            qr[did:plc:qvzn322kmcvd7xtnips5xaun], 'thread at://...';
        like is_say { client->run(qw[thread at://did:plc:qdvyf5jhuxqx667ay7k7nagl/app.bsky.feed.post/3kju327qezs2n --json]) }, qr[^{],
            'thread --json at://...';
        like is_say { client->run(qw[list-app-passwords]) },        qr[Test Suite - bsky],                'list-app-passwords';
        like is_say { client->run(qw[list-app-passwords --json]) }, qr[^\[\{],                            'list-app-passwords --json';
        like is_say { client->run(qw[notifications]) },             qr[did:plc:],                         'notifications';
        like is_say { client->run(qw[notifications --json]) },      qr[^\[\{],                            'notifications --json';
        like is_say { client->run(qw[show-session]) },              qr[did:plc:pwqewimhd3rxc4hg6ztwrcyj], 'show-session';
        like is_say { client->run(qw[show-session --json]) },       qr[^{],                               'show-session --json';
    }
};
done_testing;
__END__



( run in 1.018 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )