Metadata-Version: 2.1
Name: postodon
Version: 0.0.1
Summary: Post to Mastodon
Author-email: msleigh <msleigh@users.noreply.github.com>
Project-URL: Homepage, https://github.com/msleigh/postodon
Project-URL: Bug Tracker, https://github.com/msleigh/postodon/issues
Project-URL: CI, https://github.com/msleigh/postodon/actions
Project-URL: Changelog, https://github.com/msleigh/postodon/releases
Classifier: Development Status :: 1 - Planning
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests
Provides-Extra: dev
Requires-Dist: black ; extra == 'dev'
Provides-Extra: docs
Requires-Dist: sphinx ; extra == 'docs'
Provides-Extra: tests
Requires-Dist: pytest ; extra == 'tests'

# postodon

[![PyPI](https://img.shields.io/pypi/v/postodon.svg)](https://pypi.org/project/postodon/)
[![Changelog](https://img.shields.io/github/v/release/msleigh/postodon?include_prereleases&label=changelog)](https://github.com/msleigh/postodon/releases)
[![License](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://github.com/msleigh/postodon/blob/main/LICENSE)

Randomly posts things to Mastadon from a list using the API.

The list of posts is a JSON file:

    [
        {"content": "Text of the post", "id": 1, "status": "unposted"},
        ...,
    ]

The command `postodon` randomly selects an unposted post, posts it to Mastodon, and marks it as posted in the list. If there are no unposted items, an already-posted item is used instead.

## Installation

Install:

    python3 -m venv .venv
    source .venv/bin/activate
    pip install postodon

## Usage

### Setup

 - Register an application as described here: https://docs.joinmastodon.org/client/token/#app
 - Get an access token as described here: https://docs.joinmastodon.org/client/authorized/#flow
 - Securely store the returned `access_token` for future reference
 - Edit `config.json` to include the name of the Mastodon instance and the name of the posts file, e.g. `posts.json`

### Use

To use, put the access token in an environment variable called `AUTH_TOKEN`:

    export AUTH_TOKEN=<your_access_token_here>

To select a random post from the list without either updating the list or posting (dry-run mode):

    postodon -n

To publicly post a random post, marked as English, and update the list (mark the post having been posted):

    postodon

NB if there are no unposted posts left in the list, this will return a random post from the 'posted' selection.

To add new posts to the list for future posting, add them to the specified posts file.

## Development

To contribute to this library, first checkout the code. Then create a new virtual environment:

    cd postodon
    python -m venv .venv
    source .venv/bin/activate

Now install the dependencies and test dependencies:

    pip install -e '.[dev,tests]'

To run the tests:

    pytest
