send toots
This commit is contained in:
parent
f4eb471d79
commit
a1f17e3922
2
auth.pl
2
auth.pl
|
@ -29,12 +29,14 @@ $masto->authorize(
|
||||||
say encode_json(
|
say encode_json(
|
||||||
{
|
{
|
||||||
masto => {
|
masto => {
|
||||||
|
instance => $inst,
|
||||||
client_id => $masto->client_id,
|
client_id => $masto->client_id,
|
||||||
client_secret => $masto->client_secret,
|
client_secret => $masto->client_secret,
|
||||||
access_token => $masto->access_token,
|
access_token => $masto->access_token,
|
||||||
},
|
},
|
||||||
lobsters => {
|
lobsters => {
|
||||||
url => "https://lobste.rs",
|
url => "https://lobste.rs",
|
||||||
|
storiesdone => [],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
4
cpanfile
4
cpanfile
|
@ -1,4 +1,6 @@
|
||||||
requires "Mastodon::Client" => "0";
|
requires "Mastodon::Client" => "0.011"; # 0.010 is buggy
|
||||||
|
requires "LWP::UserAgent" => "0";
|
||||||
requires "IO::Prompt" => "0";
|
requires "IO::Prompt" => "0";
|
||||||
requires "LWP::Protocol::https" => "0";
|
requires "LWP::Protocol::https" => "0";
|
||||||
requires "JSON::Tiny" => "0";
|
requires "JSON::Tiny" => "0";
|
||||||
|
requires "File::Slurp" => "0";
|
||||||
|
|
|
@ -0,0 +1,33 @@
|
||||||
|
#!/usr/bin/env perl
|
||||||
|
use 5.010;
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Mastodon::Client;
|
||||||
|
use JSON::Tiny qw/encode_json decode_json/;
|
||||||
|
use File::Slurp;
|
||||||
|
use LWP::UserAgent;
|
||||||
|
|
||||||
|
my $s = decode_json read_file("state.json");
|
||||||
|
|
||||||
|
my $ua = new LWP::UserAgent;
|
||||||
|
$ua->agent("lobstertoot (".$ua->_agent.") - for info contact albino\@autistici.org");
|
||||||
|
my $resp = $ua->get("$s->{lobsters}->{url}/hottest.json");
|
||||||
|
die unless $resp->is_success;
|
||||||
|
my $stories = decode_json $resp->decoded_content;
|
||||||
|
|
||||||
|
my $masto = new Mastodon::Client (
|
||||||
|
name => "lobstertoot",
|
||||||
|
coerce_entities => 1,
|
||||||
|
%{ $s->{masto} },
|
||||||
|
);
|
||||||
|
|
||||||
|
for my $story (@{$stories}) {
|
||||||
|
next if grep {$_ eq $story->{short_id}} @{ $s->{lobsters}->{storiesdone} };
|
||||||
|
|
||||||
|
my $toot = "$story->{title} $story->{url} | $s->{lobsters}->{url}/s/$story->{short_id}";
|
||||||
|
for (@{ $story->{tags} }) {
|
||||||
|
$toot .= " #$_";
|
||||||
|
}
|
||||||
|
|
||||||
|
$masto->post_status($toot);
|
||||||
|
}
|
Loading…
Reference in New Issue