Break streaming entirely, update docs
This commit is contained in:
pare
e220e7cc60
commit
9e97fce2d6
S'han modificat 2 arxius amb 32 adicions i 14 eliminacions
|
@ -112,23 +112,23 @@ Error handling
|
||||||
When Mastodon.py encounters an error, it will raise an exception, generally with
|
When Mastodon.py encounters an error, it will raise an exception, generally with
|
||||||
some text included to tell you what went wrong.
|
some text included to tell you what went wrong.
|
||||||
|
|
||||||
The base class that all mastodon exceptions inherit from is the MastodonError
|
The base class that all mastodon exceptions inherit from is `MastodonError`.
|
||||||
class. If you are only interested in the fact an error was raised somewhere in
|
If you are only interested in the fact an error was raised somewhere in
|
||||||
Mastodon.py, and not the details, this is the exception you can catch.
|
Mastodon.py, and not the details, this is the exception you can catch.
|
||||||
|
|
||||||
MastodonIllegalArgumentError is generally a programming problem - you asked the
|
`MastodonIllegalArgumentError` is generally a programming problem - you asked the
|
||||||
API to do something obviously invalid (i.e. specify a privacy scope that does
|
API to do something obviously invalid (i.e. specify a privacy scope that does
|
||||||
not exist).
|
not exist).
|
||||||
|
|
||||||
MastodonFileNotFoundError and MastodonNetworkError are IO errors - could be you
|
`MastodonFileNotFoundError` and `MastodonNetworkError` are IO errors - could be you
|
||||||
specified a wrong URL, could be the internet is down or your hard drive is
|
specified a wrong URL, could be the internet is down or your hard drive is
|
||||||
dying. They inherit from MastodonIOError, for easy catching.
|
dying. They inherit from MastodonIOError, for easy catching.
|
||||||
|
|
||||||
MastodonAPIError is an error returned from the Mastodon instance - the server
|
`MastodonAPIError` is an error returned from the Mastodon instance - the server
|
||||||
has decided it can't fullfill your request (i.e. you requested info on a user that
|
has decided it can't fullfill your request (i.e. you requested info on a user that
|
||||||
does not exist).
|
does not exist).
|
||||||
|
|
||||||
MastodonRatelimitError is raised when you hit an API rate limit. You should try
|
`MastodonRatelimitError` is raised when you hit an API rate limit. You should try
|
||||||
again after a while (see the rate limiting section above).
|
again after a while (see the rate limiting section above).
|
||||||
|
|
||||||
Return values
|
Return values
|
||||||
|
@ -538,10 +538,28 @@ If async is True, the listener will listen on another thread and these methods
|
||||||
will return a handle corresponding to the open connection. The
|
will return a handle corresponding to the open connection. The
|
||||||
connection may be closed at any time by calling its close() method.
|
connection may be closed at any time by calling its close() method.
|
||||||
|
|
||||||
.. automethod:: Mastodon.user_stream
|
The streaming functions take instances of `StreamListener` as a parameter.
|
||||||
.. automethod:: Mastodon.public_stream
|
A `CallbackStreamListener` class that allows you to specify function callbacks
|
||||||
.. automethod:: Mastodon.local_stream
|
directly is included for convenience.
|
||||||
.. automethod:: Mastodon.hashtag_stream
|
|
||||||
|
.. automethod:: Mastodon.stream_user
|
||||||
|
.. automethod:: Mastodon.stream_public
|
||||||
|
.. automethod:: Mastodon.stream_local
|
||||||
|
.. automethod:: Mastodon.stream_hashtag
|
||||||
|
|
||||||
|
StreamListener
|
||||||
|
~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. autoclass:: StreamListener
|
||||||
|
.. automethod:: StreamListener.on_update
|
||||||
|
.. automethod:: StreamListener.on_notification
|
||||||
|
.. automethod:: StreamListener.on_delete
|
||||||
|
.. automethod:: StreamListener.handle_heartbeat
|
||||||
|
|
||||||
|
CallbackStreamListener
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
|
||||||
|
.. autoclass:: CallbackStreamListener
|
||||||
|
|
||||||
.. _Mastodon: https://github.com/tootsuite/mastodon
|
.. _Mastodon: https://github.com/tootsuite/mastodon
|
||||||
.. _Mastodon flagship instance: http://mastodon.social/
|
.. _Mastodon flagship instance: http://mastodon.social/
|
||||||
|
|
|
@ -1010,7 +1010,7 @@ class Mastodon:
|
||||||
###
|
###
|
||||||
# Streaming
|
# Streaming
|
||||||
###
|
###
|
||||||
def user_stream(self, listener, async=False):
|
def stream_user(self, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Streams events that are relevant to the authorized user, i.e. home
|
Streams events that are relevant to the authorized user, i.e. home
|
||||||
timeline and notifications. 'listener' should be a subclass of
|
timeline and notifications. 'listener' should be a subclass of
|
||||||
|
@ -1018,14 +1018,14 @@ class Mastodon:
|
||||||
"""
|
"""
|
||||||
return self.__stream('/api/v1/streaming/user', listener, async=async)
|
return self.__stream('/api/v1/streaming/user', listener, async=async)
|
||||||
|
|
||||||
def public_stream(self, listener, async=False):
|
def stream_public(self, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Streams public events. 'listener' should be a subclass of StreamListener
|
Streams public events. 'listener' should be a subclass of StreamListener
|
||||||
which will receive callbacks for incoming events.
|
which will receive callbacks for incoming events.
|
||||||
"""
|
"""
|
||||||
return self.__stream('/api/v1/streaming/public', listener, async=async)
|
return self.__stream('/api/v1/streaming/public', listener, async=async)
|
||||||
|
|
||||||
def local_stream(self, listener, async=False):
|
def stream_local(self, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Streams local events. 'listener' should be a subclass of StreamListener
|
Streams local events. 'listener' should be a subclass of StreamListener
|
||||||
which will receive callbacks for incoming events.
|
which will receive callbacks for incoming events.
|
||||||
|
@ -1033,7 +1033,7 @@ class Mastodon:
|
||||||
"""
|
"""
|
||||||
return self.__stream('/api/v1/streaming/public/local', listener, async=async)
|
return self.__stream('/api/v1/streaming/public/local', listener, async=async)
|
||||||
|
|
||||||
def hashtag_stream(self, tag, listener, async=False):
|
def stream_hashtag(self, tag, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Returns all public statuses for the hashtag 'tag'. 'listener' should be
|
Returns all public statuses for the hashtag 'tag'. 'listener' should be
|
||||||
a subclass of StreamListener which will receive callbacks for incoming
|
a subclass of StreamListener which will receive callbacks for incoming
|
||||||
|
|
Loading…
Referencia en una nova incidència