aboutsummaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorAljoscha Rittner <[email protected]>2022-06-24 17:58:13 +0200
committerAljoscha Rittner <[email protected]>2022-06-24 17:58:13 +0200
commitb225524d7c8f7726a1bb441e6cd605fccb94e912 (patch)
tree5f7c2a66e063b80e77b7be1fe2c24be986e70e1d /docs
parentaf59a460687864341b544159a714e4de3891ff08 (diff)
downloadmastodon.py-b225524d7c8f7726a1bb441e6cd605fccb94e912.tar.gz
Documentation for processing unknown events in streaming.
Fixes #234
Diffstat (limited to 'docs')
-rw-r--r--docs/index.rst14
1 files changed, 14 insertions, 0 deletions
diff --git a/docs/index.rst b/docs/index.rst
index 473777a..e7b1ed9 100644
--- a/docs/index.rst
+++ b/docs/index.rst
@@ -1275,6 +1275,19 @@ The streaming functions take instances of `StreamListener` as the `listener` par
1275A `CallbackStreamListener` class that allows you to specify function callbacks 1275A `CallbackStreamListener` class that allows you to specify function callbacks
1276directly is included for convenience. 1276directly is included for convenience.
1277 1277
1278For new well-known events implement the streaming function in `StreamListener` or `CallbackStreamListener`.
1279The function name is `on_` + the event name. If the event-name contains dots, use an underscore instead.
1280
1281E.g. for `'status.update'` the listener function should be named as `on_status_update`.
1282
1283It may be that future Mastodon versions will come with completely new (unknown) event names. In this
1284case a (deprecated) Mastodon.py would throw an error. If you want to avoid this in general, you can
1285override the listener function `on_unknown_event`. This has an additional parameter `name` which informs
1286about the name of the event. `unknown_event` contains the content of the event.
1287
1288Alternatively, a callback function can be passed in the `unknown_event_handler` parameter in the
1289`CallbackStreamListener` constructor.
1290
1278When in not-async mode or async mode without async_reconnect, the stream functions may raise 1291When in not-async mode or async mode without async_reconnect, the stream functions may raise
1279various exceptions: `MastodonMalformedEventError` if a received event cannot be parsed and 1292various exceptions: `MastodonMalformedEventError` if a received event cannot be parsed and
1280`MastodonNetworkError` if any connection problems occur. 1293`MastodonNetworkError` if any connection problems occur.
@@ -1294,6 +1307,7 @@ StreamListener
1294.. automethod:: StreamListener.on_notification 1307.. automethod:: StreamListener.on_notification
1295.. automethod:: StreamListener.on_delete 1308.. automethod:: StreamListener.on_delete
1296.. automethod:: StreamListener.on_conversation 1309.. automethod:: StreamListener.on_conversation
1310.. automethod:: StreamListener.on_unknown_event
1297.. automethod:: StreamListener.on_abort 1311.. automethod:: StreamListener.on_abort
1298.. automethod:: StreamListener.handle_heartbeat 1312.. automethod:: StreamListener.handle_heartbeat
1299 1313
Powered by cgit v1.2.3 (git 2.41.0)