Merge branch 'master' of github.com:halcy/Mastodon.py

pull/339/head
halcy 2023-04-23 19:20:19 +03:00
commit 137cf49435
29 zmienionych plików z 119 dodań i 96 usunięć

Wyświetl plik

@ -64,6 +64,7 @@ from .push import Mastodon as Push
from .admin import Mastodon as Admin
from .streaming_endpoints import Mastodon as Streaming
###
# The actual Mastodon class
#

Wyświetl plik

@ -9,6 +9,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
@api_version("2.7.0", "2.7.0", "3.4.0")
def create_account(self, username, password, email, agreement=False, reason=None, locale="en", scopes=_DEFAULT_SCOPES, to_file=None, return_detailed_error=False):
@ -348,7 +349,6 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('POST', f'/api/v1/accounts/{id}/remove_from_followers')
@api_version("1.0.0", "1.4.0", _DICT_VERSION_RELATIONSHIP)
def account_block(self, id):
"""

Wyświetl plik

@ -7,6 +7,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Moderation API
@ -377,7 +378,7 @@ class Mastodon(Internals):
id = self.__unpack_id(id)
return self.__api_request('GET', f'/api/v1/admin/domain_blocks/{id}')
else:
params = self.__generate_params(locals(),['limit'])
params = self.__generate_params(locals(), ['limit'])
return self.__api_request('GET', '/api/v1/admin/domain_blocks/', params)
@api_version("4.0.0", "4.0.0", _DICT_VERSION_ADMIN_DOMAIN_BLOCK)

Wyświetl plik

@ -14,6 +14,7 @@ from .utility import parse_version_string, api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Registering apps

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Conversations

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Endorsements

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Favourites
@ -59,4 +60,3 @@ class Mastodon(Internals):
params = self.__generate_params(locals())
return self.__api_request('GET', '/api/v1/bookmarks', params)

Wyświetl plik

@ -8,6 +8,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Keyword filters

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Featured hashtags

Wyświetl plik

@ -7,6 +7,7 @@ from .compat import urlparse
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Instances

Wyświetl plik

@ -22,6 +22,7 @@ from .errors import MastodonNetworkError, MastodonIllegalArgumentError, Mastodon
from .compat import urlparse, magic, PurePath
from .defaults import _DEFAULT_STREAM_TIMEOUT, _DEFAULT_STREAM_RECONNECT_WAIT_SEC
###
# Internal helpers, dragons probably
###
@ -37,7 +38,6 @@ class Mastodon():
date_time = date_time.replace(tzinfo=datetime.timezone.utc)
return date_time.timestamp()
def __get_logged_in_id(self):
"""
Fetch the logged in user's ID, with caching. ID is reset on calls to log_in.

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Lists

Wyświetl plik

@ -8,6 +8,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Media

Wyświetl plik

@ -6,6 +6,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Notifications

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Polls

Wyświetl plik

@ -8,6 +8,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Preferences
@ -68,4 +69,3 @@ class Mastodon(Internals):
params[timeline]["last_read_id"] = self.__unpack_id(last_read_id)
return self.__api_request('POST', '/api/v1/markers', params, use_json=True)

Wyświetl plik

@ -12,6 +12,7 @@ from .compat import IMPL_HAS_ECE, http_ece
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Webpush subscriptions

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Mutes and Blocks

Wyświetl plik

@ -7,6 +7,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Reports

Wyświetl plik

@ -6,6 +6,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Searching

Wyświetl plik

@ -9,6 +9,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Statuses
@ -272,7 +273,7 @@ class Mastodon(Internals):
return self.status_post(status)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS)
def status_update(self, id, status = None, spoiler_text = None, sensitive = None, media_ids = None, poll = None):
def status_update(self, id, status=None, spoiler_text=None, sensitive=None, media_ids=None, poll=None):
"""
Edit a status. The meanings of the fields are largely the same as in :ref:`status_post() <status_post()>`,
though not every field can be edited.
@ -280,12 +281,12 @@ class Mastodon(Internals):
Note that editing a poll will reset the votes.
"""
return self.__status_internal(
status = status,
media_ids = media_ids,
sensitive = sensitive,
spoiler_text = spoiler_text,
poll = poll,
edit = id
status=status,
media_ids=media_ids,
sensitive=sensitive,
spoiler_text=spoiler_text,
poll=poll,
edit=id
)
@api_version("3.5.0", "3.5.0", _DICT_VERSION_STATUS_EDIT)
@ -317,7 +318,7 @@ class Mastodon(Internals):
scheduled_at=None, poll=None, untag=False):
"""
Helper function - acts like status_post, but prepends the name of all
the users that are being replied to to the status text and retains
the users that are being replied to the status text and retains
CW and visibility if not explicitly overridden.
Note that `to_status` should be a :ref:`status dict <status dict>` and not an ID.

Wyświetl plik

@ -217,6 +217,7 @@ class StreamListener(object):
else:
handler(name, payload)
class CallbackStreamListener(StreamListener):
"""
Simple callback stream handler class.
@ -227,20 +228,19 @@ class CallbackStreamListener(StreamListener):
"""
def __init__(self,
update_handler=None,
local_update_handler=None,
delete_handler=None,
notification_handler=None,
conversation_handler=None,
unknown_event_handler=None,
status_update_handler=None,
filters_changed_handler=None,
announcement_handler=None,
announcement_reaction_handler=None,
announcement_delete_handler=None,
encryted_message_handler=None
):
update_handler=None,
local_update_handler=None,
delete_handler=None,
notification_handler=None,
conversation_handler=None,
unknown_event_handler=None,
status_update_handler=None,
filters_changed_handler=None,
announcement_handler=None,
announcement_reaction_handler=None,
announcement_delete_handler=None,
encryted_message_handler=None
):
super(CallbackStreamListener, self).__init__()
self.update_handler = update_handler
self.local_update_handler = local_update_handler

Wyświetl plik

@ -7,6 +7,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Streaming

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Follow suggestions

Wyświetl plik

@ -6,6 +6,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Timelines
@ -101,4 +102,3 @@ class Mastodon(Internals):
"""
id = self.__unpack_id(id)
return self.timeline(f'list/{id}', max_id=max_id, min_id=min_id, since_id=since_id, limit=limit, only_media=only_media, local=local, remote=remote)

Wyświetl plik

@ -5,6 +5,7 @@ from .utility import api_version
from .internals import Mastodon as Internals
class Mastodon(Internals):
###
# Reading data: Trends

Wyświetl plik

@ -24,10 +24,12 @@ def parse_version_string(version_string):
)
return version_parts
def max_version(*version_strings):
"""Returns the maximum version of all provided version strings."""
return max(version_strings, key=parse_version_string)
def api_version(created_ver, last_changed_ver, return_value_ver):
"""Version check decorator. Currently only checks Bigger Than."""
def api_min_version_decorator(function):
@ -49,6 +51,7 @@ def api_version(created_ver, last_changed_ver, return_value_ver):
return decorate(function, wrapper)
return api_min_version_decorator
###
# Dict helper class.
# Defined at top level so it can be pickled.