geotribu_cli.social.mastodon_client module¶
- class geotribu_cli.social.mastodon_client.ExtendedMastodonClient(client_id=None, client_secret=None, access_token=None, api_base_url='https://mapstodon.space/', debug_requests=None, ratelimit_method='wait', ratelimit_pacefactor=1.1, request_timeout=60, mastodon_version=None, version_check_mode='created', session=None, feature_set='mainline', user_agent='GeotribuToolbelt/0.34.3', lang='fra')¶
Bases :
Mastodon
Extended Mastodon client with custom methods and attributes.
- Lève:
MastodonError – if access token is not set
- __init__(client_id=None, client_secret=None, access_token=None, api_base_url='https://mapstodon.space/', debug_requests=None, ratelimit_method='wait', ratelimit_pacefactor=1.1, request_timeout=60, mastodon_version=None, version_check_mode='created', session=None, feature_set='mainline', user_agent='GeotribuToolbelt/0.34.3', lang='fra')¶
Instanciation class. Args are inherited.
- 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'))¶
Export account data.
- Paramètres:
dest_path_following_accounts (
Optional
[Path
]) – path to the CSV file for following accounts export. Defaults to default_dest_path_following_accounts.dest_path_lists (
Optional
[Path
]) – path to the CSV file for lists export. Defaults to default_dest_path_lists.dest_path_lists_only_accounts (
Optional
[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