Skip to main content

Tiny CLI to post simultaneously to Mastodon and Bluesky

Project description

Not my ex

Tiny CLI 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)

Getting started

Requirements

Environment variables

To repost in 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 Bluesky reposting.

To repost in 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 Mastodon reposting.

Install

$ pip install not-my-ex

Usage

CLI

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

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

API

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

from httpx import AsyncClient


async def publish(adapter, http, post):
    client = await adapter.authenticated(http)
    await client.post(post)


async def main():
    post = Post(
        text="Magic, madness, heaven, sin ",
        media=(
            Media.from_img("taylor.jpg", alt="Taylor"),
            Media.from_img("swift.jpg", alt="Swift"),
        ),
        lang="en",
    )

    async with AsyncClient() as http:
        tasks = tuple(publish(cls, http, post) for cls in (Bluesky, Mastodon))
        await gather(*tasks)

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

Contributing

The tests include Ruff and Mypy:

$ poetry install
$ poetry 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-0.0.3.tar.gz (19.6 kB view details)

Uploaded Source

Built Distribution

not_my_ex-0.0.3-py3-none-any.whl (21.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: not_my_ex-0.0.3.tar.gz
  • Upload date:
  • Size: 19.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for not_my_ex-0.0.3.tar.gz
Algorithm Hash digest
SHA256 69d57d85349c9bd13285f207095d51177f374ae3b3dc9e4e31b10a0504eae9b6
MD5 a4dc33f93f9e31ab5d9884cb284f97c6
BLAKE2b-256 2b9fa717a6c843f77b0c19dfc1ca355a4b697f44e3e8783e5513549a76b7dd1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: not_my_ex-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 21.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/23.2.0

File hashes

Hashes for not_my_ex-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 95dbf05755a56793e5df04915a0762ee184b1c2df4bbc81dd54edb79597a30d0
MD5 f942e77b28f0126d0b2273b23550a3e7
BLAKE2b-256 0905d756346c1351a9b30ee4e661f37be92316fda94d4401a9dc3a0bb26aed12

See more details on using hashes here.

Supported by

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