Skip to main content

Tiny CLI to post simultaneously to Mastodon and Bluesky

Project description

Not my ex PyPI Tests PyPI - Python Version

Tiny app to post simultaneously to Mastodon and Bluesky.

Obviously, based on cuducos/from-my-ex.

It supports:

  • Post status updates to both networks with a simple CLI command
  • Posting with images
  • Including alt text for images
  • Setting post language

It does not support:

  • Tagging other users (they would have different IDs and servers in each platform)

It used to have:

  • A simple GUI (version 0.1.1), but dropped support to focus on CLI — there are other great GUI out there by now

Getting started

Requirements

  • Python 3.9 or newer
Optionally, you can set some environment variables, but you don't have to.

Environment variables

General settings
Name Description Example Default value
NOT_MY_EX_DEFAULT_LANG 2-letter ISO 639-1 code "pt" None
To post to Bluesky
Name Description Example Default value
NOT_MY_EX_BSKY_AGENT Bluesky instance "https://bsky.social" "https://bsky.social"
NOT_MY_EX_BSKY_EMAIL Email used in Bluesky "cuducos@mailinator.com" None
NOT_MY_EX_BSKY_PASSWORD Password used in Bluesky As created in App Passwords. None

Not setting NOT_MY_EX_BSKY_EMAIL or NOT_MY_EX_BSKY_PASSWORD disables posting to Bluesky.

To post to Mastodon
Name Description Example Default value
NOT_MY_EX_MASTODON_INSTANCE Mastodon instance "https://tech.lgbt" "https://mastodon.social"
NOT_MY_EX_MASTODON_TOKEN Mastodon access token Go to your Settings, Development and then create an app to get the access token. Select the write:statuses and write:media scopes. None

Not setting NOT_MY_EX_MASTODON_TOKEN disables posting to Mastodon.

Install

$ pip install not-my-ex

Usage

CLI

$ not-my-ex post "Magic, madness, heaven, sin" --images /tmp/1989.gif

You can skip the post text; in that case, it will open $EDITOR so you can write your post.

You can skip --images or pass multiple images (e.g. --images taylor.jpg --images swift.gif).

Check --help for more details on commands and subcommand.

API

from asyncio import gather

from httpx import AsyncClient

from not_my_ex.auth import EnvAuth
from not_my_ex.bluesky import Bluesky
from not_my_ex.mastodon import Mastodon
from not_my_ex.media import Media
from not_my_ex.post import Post


async def main():
    auth = EnvAuth()
    media_tasks = tuple(
        Media.from_img(path, alt, auth.image_size_limit)
        for path, alt in (("taylor.jpg", "Taylor"), ("swift.jpg", "Swift"))
    )
    media = await gather(*media_tasks)

    post = Post("Magic, madness, heaven, sin", auth.limit, media, "en")
    async with AsyncClient() as http:
        post_tasks = tuple(cls(http).post(post) for cls in (Bluesky, Mastodon))
        await gather(*post_tasks)

In Post, limit, media and lang are optional. In Media, both alt and image_size_limit are optional.

The usage of auth.limit and auth.image_size_limit makes sure the limits are set according to the authenticated clients.

Contributing

Requires uv Python package manager. The tests include Ruff and Mypy:

$ uv run pytest

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

not_my_ex-1.2.1.tar.gz (160.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

not_my_ex-1.2.1-py3-none-any.whl (41.2 kB view details)

Uploaded Python 3

File details

Details for the file not_my_ex-1.2.1.tar.gz.

File metadata

  • Download URL: not_my_ex-1.2.1.tar.gz
  • Upload date:
  • Size: 160.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for not_my_ex-1.2.1.tar.gz
Algorithm Hash digest
SHA256 574b1123944a850445e7e9ae967d940f28afda0d12e3c17e10fc0e761d4b6356
MD5 4f39f6f257087d81812d8fb1d06f41ce
BLAKE2b-256 45a040dd969024caac9b53c57a93e5f95a708b7fda25df482f46f96f23ea7c83

See more details on using hashes here.

File details

Details for the file not_my_ex-1.2.1-py3-none-any.whl.

File metadata

  • Download URL: not_my_ex-1.2.1-py3-none-any.whl
  • Upload date:
  • Size: 41.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.17

File hashes

Hashes for not_my_ex-1.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3667b3830a573be53f351b7b9028d3deef4b8463ba46533e65fdfa06178cf0a0
MD5 111290aa9a23f5cbff2d47f563ee6018
BLAKE2b-256 1717dd51ce0e19a191d2816a8909ea25564bd56c3d59bf0b02404e6a4a2b4332

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page