App-SpreadRevolutionaryDate
view release on metacpan or search on metacpan
lib/App/SpreadRevolutionaryDate/Target/Mastodon.pm view on Meta::CPAN
#
# This file is part of App-SpreadRevolutionaryDate
#
# This software is Copyright (c) 2019-2026 by Gérald Sédrati.
#
# This is free software, licensed under:
#
# The GNU General Public License, Version 3, June 2007
#
use 5.014;
use utf8;
package App::SpreadRevolutionaryDate::Target::Mastodon;
$App::SpreadRevolutionaryDate::Target::Mastodon::VERSION = '0.54';
# ABSTRACT: Target class for L<App::SpreadRevolutionaryDate> to handle spreading on Mastodon.
use Moose;
with 'App::SpreadRevolutionaryDate::Target'
=> {worker => 'Mastodon::Client'};
use Mastodon::Client;
use Encode qw(encode decode is_utf8);
use File::Basename;
use Locale::TextDomain 'App-SpreadRevolutionaryDate';
use namespace::autoclean;
has 'instance' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'client_id' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'client_secret' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'access_token' => (
is => 'ro',
isa => 'Str',
required => 1,
);
has 'max_lenght' => (
is => 'ro',
isa => 'Int',
required => 1,
default => 300,
);
around BUILDARGS => sub {
my ($orig, $class) = @_;
my $args = $class->$orig(@_);
$args->{obj} = Mastodon::Client->new(
instance => $args->{instance},
client_id => $args->{client_id},
client_secret => $args->{client_secret},
access_token => $args->{access_token},
name => 'RevolutionaryDate');
return $args;
};
sub spread {
my ($self, $msg, $test, $img) = @_;
$test //= 0;
# Multiline message
$msg =~ s/\\n/\n/g;
if ($test) {
$msg = __("Spread on Mastodon: ") . $msg;
if ($img) {
( run in 0.503 second using v1.01-cache-2.11-cpan-8f98c5d2c55 )