commit f4eb471d79387d5651e739a0a7aa655833b8792c Author: Anonymous Date: Wed May 10 15:34:53 2017 +0100 initial commit, log in to masto diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..224b094 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +state.json diff --git a/README.md b/README.md new file mode 100644 index 0000000..5a08d1c --- /dev/null +++ b/README.md @@ -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 +``` diff --git a/auth.pl b/auth.pl new file mode 100644 index 0000000..f2adf60 --- /dev/null +++ b/auth.pl @@ -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", + }, + } +); diff --git a/cpanfile b/cpanfile new file mode 100644 index 0000000..7934647 --- /dev/null +++ b/cpanfile @@ -0,0 +1,4 @@ +requires "Mastodon::Client" => "0"; +requires "IO::Prompt" => "0"; +requires "LWP::Protocol::https" => "0"; +requires "JSON::Tiny" => "0";