Skip to main content

Yet another cross-posting tool in Python

Project description

Barkr

Barkr[^1] is a social media cross-posting tool written in Python: set it up and never worry about manually posting the same message to multiple channels ever again!

With Barkr you can setup a series of channels (e.g. social media accounts) to read messages from and / or post messages to. You can mix and match read / write modes, and add multiple accounts of the same type of channel as well without worrying that the same message will be re-posted to a channel it comes from.

Note that Barkr is limited to text posts only. Want to see that change? Start a discussion on a new issue!

[^1]: "Barkr" (missing "e") as in "entity that barks". See: dogs.

Motivation

I wrote Barkr for a personal use case after noting how much fragmentation there currently is (as of 2023) in the social media space, as a way to reduce the cost of engaging with multiple social media platforms, and also as a (very simple) way to practice using threads in Python.

Installation

Use the package manager pip to install barkr.

pip install barkr

Usage

Create a Python script and specify all the channels you want to use. Channel connections are present in the barkr.connections module.

A simple script showcasing how to set up three Mastodon connections with multiple modes that can run in the background is outlined below:

from barkr.main import Barkr

from barkr.connections import (
    ConnectionMode,
    BlueskyConnection,
    DiscordConnection,
    MastodonConnection,
    RSSConnection,
    TelegramConnection,
    TwitterConnection,
)

from barkr.models import Message

barkr = Barkr(
    [
        # Barkr will read new messages posted by this account, and queue them to
        # other accounts on write mode, but will not post anything to it.
        MastodonConnection(
            "Read only connection",
            [ConnectionMode.READ],
            "<ACCESS TOKEN HERE>",
            "<INSTANCE URL HERE>",
        ),
        # Barkr will write queued messages to this account, but will not read anything
        # new posted to this account or queue anything from this account to other ones.
        DiscordConnection(
            "Write only connection",
            [ConnectionMode.WRITE],
            "<BOT TOKEN ID HERE>",
            "<CHANNEL ID HERE>",
        ),
        # Barkr will read new messages from this account to be queued onto others, and will
        # post new messages from other channels into this one as well.
        BlueskyConnection(
            "R/W connection",
            [ConnectionMode.READ, ConnectionMode.WRITE],
            "<BLUESKY HANDLE HERE>",
            "<PASSWORD / APP PASSWORD HERE>",
        ),
        # Another example using Twitter -- note that the TwitterConnection only
        # supports write-only mode through the Twitter V2 API
        TwitterConnection(
            "Write only Twitter Connection",
            [ConnectionMode.WRITE],
            "<CONSUMER KEY HERE>",
            "<CONSUMER SECRET HERE>",
            "<ACCESS KEY HERE>",
            "<ACCESS SECRET HERE>",
            "<BEARER TOKEN HERE>",
        ),
        # One more, showcasing a Telegram write-only connection
        TelegramConnection(
            "Write only Telegram connection",
            [ConnectionMode.WRITE],
            "<TELEGRAM BOT TOKEN HERE>",
            "<TELEGRAM CHAT / CHANNEL ID HERE>",
        ),
        # You can also read from an RSS feed!
        RSSConnection(
            "Read only RSS connection",
            [ConnectionMode.READ],
            "<RSS FEED URL HERE>"
        ),
    ]
)

# Blocking: will start reading and writing threads to keep the connections in sync
barkr.start()

# Non-blocking, if you only need to write messages to your connections
barkr.write_message(
    Message(
        id="123456",
        message="Hello, world!",
    )
)

Always keep in mind proper secret management practices when using Barkr: instead of hardcoding access tokens / cookies / user and passwords, use tools like environment variables, dotenv or other secret managers!

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change. Contributions for issues that are already open by maintainers are welcome and encouraged.

Please make sure to update tests as appropriate; a minimum coverage of 80% is expected (and enforced by Github Actions!).

License

This project is licensed under the GNU Affero General Public License v3.0.

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

barkr-0.11.1.tar.gz (34.7 kB view details)

Uploaded Source

Built Distribution

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

barkr-0.11.1-py3-none-any.whl (42.4 kB view details)

Uploaded Python 3

File details

Details for the file barkr-0.11.1.tar.gz.

File metadata

  • Download URL: barkr-0.11.1.tar.gz
  • Upload date:
  • Size: 34.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for barkr-0.11.1.tar.gz
Algorithm Hash digest
SHA256 bbc37972fd4888697b58435f70b4445172df0b3123a5464f4464b85ad502751f
MD5 2bce96bfef4472275ee237c43a8a1844
BLAKE2b-256 6157421c82186e8e4a46929efda61ac69bed335768ac89ea9d3f3cea2ae04eb0

See more details on using hashes here.

File details

Details for the file barkr-0.11.1-py3-none-any.whl.

File metadata

  • Download URL: barkr-0.11.1-py3-none-any.whl
  • Upload date:
  • Size: 42.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for barkr-0.11.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eca20c358199eb9140d5ad4959d17574da62dc7cff221678739782c4a7d9ee44
MD5 09f03f9a18639975ef94d490670b8137
BLAKE2b-256 5816ac32ecd8222e0e55b0c902ac4fecf1c00ca84d9f967a93dc8b388331297b

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