initial commit, log in to masto

This commit is contained in:
Anonymous 2017-05-10 15:34:53 +01:00
commit f4eb471d79
4 changed files with 53 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
state.json

8
README.md Normal file
View File

@ -0,0 +1,8 @@
# lobstertoot
## making it work
```sh
cpanm --installdeps . # get dependencies
perl auth.pl > state.json # write config file
perl lobstertoot.pl # run the thing, put it in crontab, whatever
```

40
auth.pl Normal file
View File

@ -0,0 +1,40 @@
#!/usr/bin/env perl
use 5.010;
use strict;
use warnings;
use Mastodon::Client;
use YAML::Tiny;
use IO::Prompt;
use JSON::Tiny qw/encode_json/;
my $inst = prompt("Instance hostname (e.g. mastodon.social): ")->{value};
my $masto = new Mastodon::Client (
instance => $inst,
name => "lobstertoot",
website => "https://git.fuwafuwa.moe/albino/lobstertoot",
scopes => ["write"],
coerce_entities => 1,
);
$masto->register();
say STDERR "Authorize your mastodon account at " . $masto->authorization_url . " and enter the access code here.";
my $acode = prompt("Access code: ")->{value};
$masto->authorize(
access_code => $acode,
);
say encode_json(
{
masto => {
client_id => $masto->client_id,
client_secret => $masto->client_secret,
access_token => $masto->access_token,
},
lobsters => {
url => "https://lobste.rs",
},
}
);

4
cpanfile Normal file
View File

@ -0,0 +1,4 @@
requires "Mastodon::Client" => "0";
requires "IO::Prompt" => "0";
requires "LWP::Protocol::https" => "0";
requires "JSON::Tiny" => "0";