diff options
author | Lorenz Diener <[email protected]> | 2019-06-22 15:51:57 +0200 |
---|---|---|
committer | Lorenz Diener <[email protected]> | 2019-06-22 15:51:57 +0200 |
commit | 903068887e02bc514eaf94520b5dc0827ebfc8c0 (patch) | |
tree | 9d130f0b17bee654b52b861cf5cfb6ee32ecfd39 /mastodon | |
parent | 9129a65b885053cb7571e00d5b003106e436ca0b (diff) | |
download | mastodon.py-903068887e02bc514eaf94520b5dc0827ebfc8c0.tar.gz |
Add local hashtag streaming
Diffstat (limited to 'mastodon')
-rw-r--r-- | mastodon/Mastodon.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index 9b08bcf..ca38708 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -2504,14 +2504,19 @@ class Mastodon: | |||
2504 | return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 2504 | return self.__stream('/api/v1/streaming/public/local', listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) |
2505 | 2505 | ||
2506 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) | 2506 | @api_version("1.1.0", "1.4.2", __DICT_VERSION_STATUS) |
2507 | def stream_hashtag(self, tag, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 2507 | def stream_hashtag(self, tag, listener, local=False, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |
2508 | """ | 2508 | """ |
2509 | Stream for all public statuses for the hashtag 'tag' seen by the connected | 2509 | Stream for all public statuses for the hashtag 'tag' seen by the connected |
2510 | instance. | 2510 | instance. |
2511 | |||
2512 | Set local to True to only get local statuses. | ||
2511 | """ | 2513 | """ |
2512 | if tag.startswith("#"): | 2514 | if tag.startswith("#"): |
2513 | raise MastodonIllegalArgumentError("Tag parameter should omit leading #") | 2515 | raise MastodonIllegalArgumentError("Tag parameter should omit leading #") |
2514 | return self.__stream("/api/v1/streaming/hashtag?tag={}".format(tag), listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | 2516 | base = '/api/v1/streaming/hashtag' |
2517 | if local: | ||
2518 | base += '/local' | ||
2519 | return self.__stream("{}?tag={}".format(base, tag), listener, run_async=run_async, timeout=timeout, reconnect_async=reconnect_async, reconnect_async_wait_sec=reconnect_async_wait_sec) | ||
2515 | 2520 | ||
2516 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS) | 2521 | @api_version("2.1.0", "2.1.0", __DICT_VERSION_STATUS) |
2517 | def stream_list(self, id, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): | 2522 | def stream_list(self, id, listener, run_async=False, timeout=__DEFAULT_STREAM_TIMEOUT, reconnect_async=False, reconnect_async_wait_sec=__DEFAULT_STREAM_RECONNECT_WAIT_SEC): |