From ed00bca2e1c60a834d541dcf6b212f75aaab69ca Mon Sep 17 00:00:00 2001 From: Sanko Robinson Date: Sat, 27 Jan 2024 18:47:24 -0500 Subject: [PATCH] Checking in changes prior to tagging of version 0.03. Changelog diff is: diff --git a/Changes b/Changes index a52b870..a13d3fc 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ Revision history for Perl extension App-bsky {{$NEXT}} +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 --- Changes | 4 ++++ META.json | 4 ++-- README.md | 46 +++++++++++++++------------------------------- cpanfile | 2 +- lib/App/bsky.pm | 27 +++++++++++++++++++++------ script/bsky | 40 ++++++++++++++-------------------------- t/01_client.t | 11 ++++++++--- 7 files changed, 65 insertions(+), 69 deletions(-) diff --git a/Changes b/Changes index a52b870..a13d3fc 100644 --- a/Changes +++ b/Changes @@ -2,6 +2,10 @@ Revision history for Perl extension App-bsky {{$NEXT}} +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 diff --git a/META.json b/META.json index 64aa850..ea4e108 100644 --- a/META.json +++ b/META.json @@ -59,7 +59,7 @@ }, "runtime" : { "requires" : { - "At" : "0.14", + "At" : "0.15", "File::HomeDir" : "0", "Getopt::Long" : "0", "JSON::Tiny" : "0", @@ -88,7 +88,7 @@ "web" : "https://github.com/sanko/App-bsky" } }, - "version" : "0.02", + "version" : "0.03", "x_authority" : "cpan:SANKO", "x_serialization_backend" : "JSON::PP version 4.16", "x_static_install" : 1 diff --git a/README.md b/README.md index a825561..0aee34e 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Display posts from timeline. ## thread ``` -thread at://did:plc:qdvyf5jhuxqx667ay7k7nagl/app.bsky.feed.post/3kju327qezs2n +thread at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w ``` Show a thread. @@ -150,65 +150,55 @@ Create a new post. ## like ``` -bsky like [uri] +bsky like at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w ``` Like a post. -TODO - -### Options +## unlike ``` -uri +bsky unlike at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w + +bsky unlike at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.like/3kjyml72tqu2y ``` +Unlike a post. Either the direct feed URI or the like URI printed by `bsky like ...`. + ## likes ``` -bsky likes [uri] +bsky likes at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w ``` Show likes on a post. -TODO - ### Options ``` -uri +--json boolean flag; content is printed as JSON objects if given ``` ## repost ``` -bsky repost [uri] +bsky repost at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w ``` Repost the post. -TODO - -### Options - -``` -uri -``` - ## reposts ``` -bsky reposts [uri] +bsky reposts at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w ``` Show reposts of the post. -TODO - ### Options ``` -uri +--json boolean flag; content is printed as JSON objects if given ``` ## follow @@ -342,16 +332,10 @@ Show blocks. ## delete ``` -bsky delete [cid] +bsky delete at://did:p... ``` -Delete an item. - -### Options - -``` -cid -``` +Delete a post, repost, etc. ## notifications diff --git a/cpanfile b/cpanfile index 8a48737..d4b845b 100644 --- a/cpanfile +++ b/cpanfile @@ -1,5 +1,5 @@ requires 'perl', '5.038000'; # class syntax -requires 'At', '0.14'; +requires 'At', '0.15'; requires 'Getopt::Long'; requires 'Pod::Text::Color'; requires 'Path::Tiny'; diff --git a/lib/App/bsky.pm b/lib/App/bsky.pm index 2259a9f..5bc5386 100644 --- a/lib/App/bsky.pm +++ b/lib/App/bsky.pm @@ -1,4 +1,4 @@ -package App::bsky 0.02 { +package App::bsky 0.03 { use v5.38; use utf8; use Bluesky; @@ -301,8 +301,6 @@ package App::bsky 0.02 { } method cmd_like ($uri) { # can take the post uri - - #~ GetOptionsFromArray( \@args, 'json!' => \my $json ); my $res = $bsky->like($uri); $res // return; $self->say( $res->{uri}->as_string ); @@ -336,11 +334,28 @@ package App::bsky 0.02 { } method cmd_repost ($uri) { - ...; + my $res = $bsky->repost($uri); + $res // return; + $self->say( $res->{uri}->as_string ); } - method cmd_reposts ($uri) { - ...; + method cmd_reposts ( $uri, @args ) { + GetOptionsFromArray( \@args, 'json!' => \my $json ); + my @reposts; + my $cursor = (); + do { + my $reposts = $bsky->feed_getRepostedBy( $uri, undef, 100, $cursor ); + push @reposts, @{ $reposts->{repostedBy} }; + $cursor = $reposts->{cursor}; + } while ($cursor); + if ($json) { + $self->say( JSON::Tiny::to_json [ map { $_->_raw } @reposts ] ); + } + else { + $self->say( '%s%s%s%s', color('red'), $_->handle->_raw, color('reset'), defined $_->displayName ? ' [' . $_->displayName . ']' : '' ) + for @reposts; + } + scalar @reposts; } method cmd_follow ($actor) { # takes handle or did diff --git a/script/bsky b/script/bsky index aa7cd50..52cc3bb 100644 --- a/script/bsky +++ b/script/bsky @@ -113,7 +113,7 @@ Display posts from timeline. =head2 thread - thread at://did:plc:qdvyf5jhuxqx667ay7k7nagl/app.bsky.feed.post/3kju327qezs2n + thread at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w Show a thread. @@ -130,51 +130,43 @@ Create a new post. =head2 like - bsky like [uri] + bsky like at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w Like a post. -TODO +=head2 unlike -=head3 Options + bsky unlike at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w + + bsky unlike at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.like/3kjyml72tqu2y - uri +Unlike a post. Either the direct feed URI or the like URI printed by C. =head2 likes - bsky likes [uri] + bsky likes at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w Show likes on a post. -TODO - =head3 Options - uri + --json boolean flag; content is printed as JSON objects if given =head2 repost - bsky repost [uri] + bsky repost at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w Repost the post. -TODO - -=head3 Options - - uri - =head2 reposts - bsky reposts [uri] + bsky reposts at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post/3kjyoh75qne2w Show reposts of the post. -TODO - =head3 Options - uri + --json boolean flag; content is printed as JSON objects if given =head2 follow @@ -278,13 +270,9 @@ Show blocks. =head2 delete - bsky delete [cid] - -Delete an item. - -=head3 Options + bsky delete at://did:p... - cid +Delete a post, repost, etc. =head2 notifications diff --git a/t/01_client.t b/t/01_client.t index b6196c9..b6bea87 100644 --- a/t/01_client.t +++ b/t/01_client.t @@ -162,7 +162,7 @@ subtest 'live' => sub { like is_say { client->run(qw[unblock sankor.bsky.social]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.block], 'unblock sankor.bsky.social'; }; - subtest 'post/delete' => sub { + subtest 'post/like/repost/reposts/delete' => sub { like my $uri = is_say { client->run(qw[post Demo]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.feed.post], 'post Demo'; sleep 1; # sometimes the service has to catch up ok client->run( 'like', $uri ), 'like at://...'; @@ -171,7 +171,12 @@ subtest 'live' => sub { sleep 1; ok client->run( 'like', $uri ), 'like at://...'; sleep 1; - ok client->run( 'delete', $uri ), 'delete at://...'; + 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://...'; @@ -179,7 +184,7 @@ subtest 'live' => sub { '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:pwqewimhd3rxc4hg6ztwrcyj], 'notifications'; + 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';