geotribu_cli.social.mastodon_client module¶
- class geotribu_cli.social.mastodon_client.ExtendedMastodonClient(access_token=None, api_base_url='https://mapstodon.space/', **kwargs)¶
Bases :
MastodonExtended Mastodon client with custom methods and attributes.
- Lève:
MastodonError – if access token is not set
- __init__(access_token=None, api_base_url='https://mapstodon.space/', **kwargs)¶
Instanciation class. Other args are inherited from Mastodon.
- broadcast_comment(in_comment)¶
Post the latest comment to Mastodon.
- comment_already_broadcasted(comment_id)¶
Check if comment has already been broadcasted on the media.
- comment_to_media(in_comment)¶
Format comment to fit media size and publication rules.
- csv_accounts_columns_names = ['Account address', 'Show boosts', 'Notify on new posts', 'Languages']¶
- export_accounts(mastodon_accounts, dest_csv_path=PosixPath('/home/runner/.geotribu/mastodon/export/mastodon_comptes_suivis_geotribu.csv'), default_instance='mapstodon.space')¶
Export Mastodon following accounts into CSV file as web UI.
- Paramètres:
- Type renvoyé:
- Renvoie:
path to the CSV file
- export_data(dest_path_following_accounts=PosixPath('/home/runner/.geotribu/mastodon/export/mastodon_comptes_suivis_geotribu.csv'), dest_path_lists=PosixPath('/home/runner/.geotribu/mastodon/export/mastodon_listes_geotribu.csv'), dest_path_lists_only_accounts=PosixPath('/home/runner/.geotribu/mastodon/export/mastodon_comptes_des_listes_geotribu.csv'))¶
Export account data.
- Paramètres:
dest_path_following_accounts (
None|Path) – path to the CSV file for following accounts export. Defaults to default_dest_path_following_accounts.dest_path_lists (
Path|None) – path to the CSV file for lists export. Defaults to default_dest_path_lists.dest_path_lists_only_accounts (
None|Path) – path to the CSV file for only accounts from lists export. Defaults to default_dest_path_lists_only_accounts.
- Lève:
MastodonAPIError – when it’s impossible to perform API request for profile information.
- Type renvoyé:
- Renvoie:
tuple of paths of exported files
- export_lists(mastodon_lists, dest_csv_path=PosixPath('/home/runner/.geotribu/mastodon/export/mastodon_listes_geotribu.csv'), default_instance='mapstodon.space')¶
Export lists.
- Paramètres:
- Type renvoyé:
- Renvoie:
path to the CSV file
- classmethod full_account_with_instance(account, default_instance='mapstodon.space')¶
Make sure the account contains instance domain.
- Paramètres:
- Renvoie:
account with default instance if not present
Example:
>>> print(ExtendedMastodonClient.full_account_with_instance(account={"acct": "datagouvfr@social.numerique.gouv.fr"})) datagouvfr@social.numerique.gouv.fr >>> print(ExtendedMastodonClient.full_account_with_instance(account={"acct": "leaflet"})) leaflet@mapstodon.space >>> print(ExtendedMastodonClient.full_account_with_instance(account={"acct": "opengisch"}, default_instance="fosstodon.org)) opengisch@fosstodon.org
- static render_status(in_comment, text)¶
Fill the status template with a comment and the text to display.