Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

multitoeter

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

multitoeter

Send out messages to Mastodon and Twitter using one simplistic unified API

  • 2
  • PyPI
  • Socket score

Maintainers
1

📢 MultiToeter

Introduction

MultiToeter is a python library providing a simplified unified API for sending messages to both the Twitter and Mastodon platform at the same time.

Usage

# install through pip
pip install multitoeter

Initialize through autoinit

MultiToeter support initializing your keys and secrets, needed for connecting to the Twitter and Mastodon API, through environment variables or through a .env file. Below are two examples on how to use this. You can mix and match these two methods. The priority is currently to try environment variables first followed by the .env file.

# Simple script to send a message through MultiToeter
# Save as: test.py
from multitoeter import autoinit_multitoeter

mt = autoinit_multitoeter()

toeter = mt.toeter('Testing MultiToeter API autoinit')
toeter = mt.toeter('Reply message', in_reply_to=toeter)
# environment variable example
# only use mastodon in this example
MASTODON_ACCESS_TOKEN=<..> MASTODON_BASE_URL=https://mstdn.science python test.py 
# .env file example
MASTODON_ACCESS_TOKEN=<..>
MASTODON_BASE_URL=https://mstdn.science

TWITTER_CONSUMER_KEY=<..>
TWITTER_CONSUMER_SECRET=<..>
TWITTER_ACCESS_TOKEN=<..>
TWITTER_ACCESS_TOKEN_SECRET=<..>

# Now run test.py:
# python test.py 

Initialize in code

A secondary approach is to initialize MultiToeter in code instead of using the autoinit. This gives you more flexibility and allows you to use more than one account for the same platform should you need it.

from multitoeter import Mastodon, Twitter, MultiToeter

mastodon1 = Mastodon(
  access_token="<..>",
  api_base_url="https://mstdn.science"
)
mastodon2 = Mastodon(
  access_token="<..>",
  api_base_url="https://mstdn.social/"
)

twitter1 = Twitter(
  consumer_key="<..>"
  consumer_secret="<..>"
  access_token="<..>"
  access_token_secret="<..>"
)

multi = MultiToeter({'mastodon1': mastodon1, 'mastodon2': mastodon2, 'twitter': twitter1})

toeter = multi.toeter("Test post via MultiToeter API")
toeter = multi.toeter("Test reply via MultiToeter API", in_reply_to=toeter)

Adding media files

Limited support for media files is available. The unified API expects you to point to the media files directly.

# Assume that the file test.jpg exists
from multitoeter import autoinit_multitoeter

mt = autoinit_multitoeter()

toeter = mt.toeter('Testing MultiToeter API autoinit', media_files=['test.jpg'])

FAQs


Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc