Add list streaming
This commit is contained in:
pare
75aebac744
commit
7ed769b37a
S'han modificat 2 arxius amb 15 adicions i 10 eliminacions
|
@ -585,7 +585,7 @@ will return a handle corresponding to the open connection. The
|
||||||
connection may be closed at any time by calling the handles close() method, and the
|
connection may be closed at any time by calling the handles close() method, and the
|
||||||
status of the connection can be verified calling is_alive() on the handle.
|
status of the connection can be verified calling is_alive() on the handle.
|
||||||
|
|
||||||
The streaming functions take instances of `StreamListener` as a parameter.
|
The streaming functions take instances of `StreamListener` as the `listener` parameter.
|
||||||
A `CallbackStreamListener` class that allows you to specify function callbacks
|
A `CallbackStreamListener` class that allows you to specify function callbacks
|
||||||
directly is included for convenience.
|
directly is included for convenience.
|
||||||
|
|
||||||
|
@ -593,6 +593,7 @@ directly is included for convenience.
|
||||||
.. automethod:: Mastodon.stream_public
|
.. automethod:: Mastodon.stream_public
|
||||||
.. automethod:: Mastodon.stream_local
|
.. automethod:: Mastodon.stream_local
|
||||||
.. automethod:: Mastodon.stream_hashtag
|
.. automethod:: Mastodon.stream_hashtag
|
||||||
|
.. automethod:: Mastodon.stream_list
|
||||||
|
|
||||||
StreamListener
|
StreamListener
|
||||||
~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~
|
||||||
|
|
|
@ -1165,25 +1165,21 @@ class Mastodon:
|
||||||
def stream_user(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.
|
||||||
StreamListener which will receive callbacks for incoming events.
|
|
||||||
"""
|
"""
|
||||||
return self.__stream('/api/v1/streaming/user', listener, async=async)
|
return self.__stream('/api/v1/streaming/user', listener, async=async)
|
||||||
|
|
||||||
@api_version("1.1.0")
|
@api_version("1.1.0")
|
||||||
def stream_public(self, listener, async=False):
|
def stream_public(self, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Streams public events. 'listener' should be a subclass of StreamListener
|
Streams public 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)
|
||||||
|
|
||||||
@api_version("1.1.0")
|
@api_version("1.1.0")
|
||||||
def stream_local(self, listener, async=False):
|
def stream_local(self, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Streams local events. 'listener' should be a subclass of StreamListener
|
Streams local public events.
|
||||||
which will receive callbacks for incoming events.
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
return self.__stream('/api/v1/streaming/public/local', listener, async=async)
|
return self.__stream('/api/v1/streaming/public/local', listener, async=async)
|
||||||
|
|
||||||
|
@ -1191,13 +1187,21 @@ class Mastodon:
|
||||||
def stream_hashtag(self, tag, listener, async=False):
|
def stream_hashtag(self, tag, listener, async=False):
|
||||||
"""
|
"""
|
||||||
Stream for all public statuses for the hashtag 'tag' seen by the connected
|
Stream for all public statuses for the hashtag 'tag' seen by the connected
|
||||||
instance. 'listener' should be a subclass of StreamListener which will receive
|
instance.
|
||||||
callbacks for incoming events.
|
|
||||||
"""
|
"""
|
||||||
if tag.startswith("#"):
|
if tag.startswith("#"):
|
||||||
raise MastodonIllegalArgumentError("Tag parameter should omit leading #")
|
raise MastodonIllegalArgumentError("Tag parameter should omit leading #")
|
||||||
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener)
|
return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener)
|
||||||
|
|
||||||
|
@api_version("2.1.0")
|
||||||
|
def stream_list(self, id, listener, async=False):
|
||||||
|
"""
|
||||||
|
Stream events for the current user, restricted to accounts on the given
|
||||||
|
list.
|
||||||
|
"""
|
||||||
|
id = self.__unpack_id(id)
|
||||||
|
return self.__stream("/api/v1/streaming/list?list={}".format(id), listener)
|
||||||
|
|
||||||
###
|
###
|
||||||
# Internal helpers, dragons probably
|
# Internal helpers, dragons probably
|
||||||
###
|
###
|
||||||
|
|
Loading…
Referencia en una nova incidència