"""Initialize Mastodon.py, login the account and register an application""" from os import getenv from dotenv import load_dotenv from mastodon import Mastodon # ----- load .env ----- # load_dotenv() # ----- register application ----- # Mastodon.create_app( getenv("MASTODON_APP_NAME"), api_base_url = str(getenv("MASTODON_URL")), to_file = getenv("MASTODON_CLIENT_SECRET") ) # ----- login Mastodon account ----- # mastodon = Mastodon( client_id = getenv("MASTODON_CLIENT_SECRET"), api_base_url = getenv("MASTODON_URL") ) mastodon.log_in( getenv("MASTODON_USERNAME"), getenv("MASTODON_PASSWORD"), to_file = getenv("MASTODON_USER_SECRET") ) # ----- post test toot ----- # mastodon.toot("Hello World")