The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

App::Toot::Config - load and verify the config

SYNOPSIS

 use App::Toot::Config;
 my $config = App::Toot::Config->load( 'section name' );

DESCRIPTION

App::Toot::Config loads settings for App::Toot.

SUBROUTINES

load( 'section name' )

Reads, verifies, and returns the config.

ARGUMENTS

The defined section name is required and dies if not found in the loaded config.

RETURNS

Returns a hashref of the loaded config for the defined section name.

CONFIGURATION

To post to Mastodon, you need to provide the account's oauth credentials in the file config.ini.

An example is provided as part of this distribution. The user running the toot script, for example through cron, will need access to the configuration file.

To set up the configuration file, copy config.ini.example into one of the following locations:

$ENV{HOME}/.config/toot/config.ini
/etc/toot/config.ini

After creating the file, edit and update the values in the default section to match the account's oauth credentials.

 [default]
 instance = mastodon.social
 username = youruser
 client_id = OKE98_kdno_NOTAREALCLIENTID
 client_secret = mkjklnv_NOTAREALCLIENTSECRET
 access_token = jo83_NOTAREALACCESSTOKEN

NOTE: If the $ENV{HOME}/.config/toot/ directory exists, config.ini will be loaded from there regardless of a config file in /etc/toot/.

Required keys

The following keys are required for each section:

instance

The Mastodon server name the account belongs to.

username

The account name for the Mastodon server defined in instance.

client_id

The client_id as provided for the username on the instance.

client_secret

The client_secret as provided for the username on the instance.

access_token

The access_token as provided for the username on the instance.

Additional accounts

Multiple accounts can be configured with different sections after the default section.

 [default]
 instance = mastodon.social
 username = youruser
 client_id = OKE98_kdno_NOTAREALCLIENTID
 client_secret = mkjklnv_NOTAREALCLIENTSECRET
 access_token = jo83_NOTAREALACCESSTOKEN
 [development]
 instance = botsin.space
 username = yourdeveluser
 client_id = Ijjkn_STILLNOTAREALCLIENTID
 client_secret = u7hhd_STILLNOTAREALCLIENTSECRET
 access_token = D873_SKILLNOTAREALACCESSTOKEN

The section name, development in the example above, can be named anything as long as it's unique with the other section names.

COPYRIGHT AND LICENSE

Copyright (c) 2023 Blaine Motsinger under the MIT license.

AUTHOR

Blaine Motsinger blaine@renderorange.com