1 """Mastodon util functions."""
3 from __future__
import annotations
5 from mastodon
import Mastodon
7 from .const
import ACCOUNT_USERNAME, DEFAULT_NAME, INSTANCE_DOMAIN, INSTANCE_URI
11 base_url: str, client_id: str, client_secret: str, access_token: str
13 """Create a Mastodon client with the api base url."""
15 api_base_url=base_url,
17 client_secret=client_secret,
18 access_token=access_token,
23 instance: dict[str, str] |
None, account: dict[str, str] |
None
25 """Construct a mastodon username from the account and instance."""
26 if instance
and account:
28 f
"@{account[ACCOUNT_USERNAME]}@"
29 f
"{instance.get(INSTANCE_URI, instance.get(INSTANCE_DOMAIN))}"
Mastodon create_mastodon_client(str base_url, str client_id, str client_secret, str access_token)
str construct_mastodon_username(dict[str, str]|None instance, dict[str, str]|None account)