App-bsky
view release on metacpan or search on metacpan
lib/App/bsky.pm view on Meta::CPAN
else {
$profile->throw unless $profile;
$self->say( 'DID: %s', $profile->{did} );
$self->say( 'Handle: %s', $profile->{handle} );
$self->say( 'DisplayName: %s', $profile->{displayName} // '' );
$self->say( 'Description: %s', $profile->{description} // '' );
$self->say( 'Follows: %d', $profile->{followsCount} );
$self->say( 'Followers: %d', $profile->{followersCount} );
$self->say( 'Avatar: %s', $profile->{avatar} ) if $profile->{avatar};
$self->say( 'Banner: %s', $profile->{banner} ) if $profile->{banner};
$self->say('Blocks you: yes') if $profile->{viewer}{blockedBy} // ();
$self->say('Following: yes') if $profile->{viewer}{following} // ();
$self->say('Muted: yes') if $profile->{viewer}{muted} // ();
}
1;
}
method cmd_updateprofile (@args) {
GetOptionsFromArray(
\@args,
'avatar=s' => \my $avatar,
lib/App/bsky.pm view on Meta::CPAN
my $res = $bsky->block($actor);
$res || $res->throw;
$self->say( $res->{uri}->as_string );
}
# TODO
method cmd_unblock ($actor) { # takes handle or did
my $profile = $bsky->getProfile($actor);
my $uri = $profile->{viewer}{blocking} // return $self->err("You are not blocking $actor");
$bsky->deleteBlock($uri);
$self->say("Unblocked $actor");
}
# TODO
method cmd_blocks (@args) {
GetOptionsFromArray( \@args, 'json!' => \my $json );
my @blocks;
my $cursor = ();
do {
my $follows = $bsky->at->get( 'app.bsky.graph.getBlocks', { limit => 100, cursor => $cursor } );
push @blocks, @{ $follows->{blocks} };
t/01_client.t view on Meta::CPAN
like is_say { client->run(qw[followers]) }, qr[deal.bsky.social], 'followers';
like is_say { client->run(qw[followers --json]) }, qr[^\[\{], 'followers --json';
like is_say { client->run(qw[followers --handle sankorobinson.com]) }, qr[atproto.com], 'followers --handle sankorobinson.com';
like is_say { client->run(qw[followers --json --handle sankorobinson.com]) }, qr[bsky\.app],
'followers --json --handle sankorobinson.com';
like is_say { client->run(qw[followers --json -H sankorobinson.com]) }, qr[bsky\.app], 'followers --json -H sankorobinson.com';
};
subtest 'follow/unfollow' => sub {
skip_all 'sankorobinson.com is already followed; might be a race condition with another smoker'
if is_say { client->run(qw[follows]) } =~ qr[sankorobinson.com];
skip_all 'sankorobinson.com is blocked and cannot be followed; might be a race condition with another smoker'
if is_say { client->run(qw[blocks]) } =~ qr[sankorobinson.com];
sleep 1;
like is_say { client->run(qw[follow sankorobinson.com]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.follow],
'follow sankorobinson.com';
sleep 1;
like is_say { client->run(qw[follows]) }, qr[sankorobinson.com], 'follows';
sleep 1; # sometimes the service has to catch up
like is_say { client->run(qw[unfollow sankorobinson.com]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.follow],
'unfollow sankorobinson.com';
sleep 1;
t/01_client.t view on Meta::CPAN
sleep 1; # sometimes the service has to catch up
like is_say { client->run(qw[unfollow did:plc:2lk3pbakx2erxgotvzyeuyem]) },
qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.follow], 'unfollow did:plc:2lk3pbakx2erxgotvzyeuyem';
};
todo 'using random images pulled from the web... things may go wrong' => sub {
like is_say {
client->run(qw[update-profile --avatar https://cataas.com/cat?width=100 --banner https://cataas.com/cat?width=1000])
}, qr[did:plc:pwqewimhd3rxc4hg6ztwrcyj], 'update-profile --avatar ... --banner ...';
};
subtest 'block/unblock' => sub {
skip_all 'sankorobinson.com is already blocked; might be a race condition with another smoker'
if is_say { client->run(qw[blocks]) } =~ qr[sankorobinson.com];
#~ skip_all 'testing!';
todo 'service might be low updating profile info...' => sub {
like is_say { client->run(qw[block sankorobinson.com]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.block],
'block sankorobinson.com';
};
sleep 1; # sometimes the service has to catch up
like is_say { client->run(qw[blocks]) }, qr[sankorobinson.com], 'blocks';
like is_say { client->run(qw[unblock sankorobinson.com]) }, qr[at://did:plc:pwqewimhd3rxc4hg6ztwrcyj/app.bsky.graph.block],
( run in 0.656 second using v1.01-cache-2.11-cpan-97f6503c9c8 )