From f4eb471d79387d5651e739a0a7aa655833b8792c Mon Sep 17 00:00:00 2001 From: Anonymous Date: Wed, 10 May 2017 15:34:53 +0100 Subject: [PATCH] initial commit, log in to masto --- .gitignore | 1 + README.md | 8 ++++++++ auth.pl | 40 ++++++++++++++++++++++++++++++++++++++++ cpanfile | 4 ++++ 4 files changed, 53 insertions(+) create mode 100644 .gitignore create mode 100644 README.md create mode 100644 auth.pl create mode 100644 cpanfile 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";