aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenz Diener <[email protected]>2019-04-28 14:28:05 +0200
committerLorenz Diener <[email protected]>2019-04-28 14:28:05 +0200
commita29d278bf9cacf5f888561564f112312707e32fd (patch)
treea85fb9da87db5c99c4d19d062ce5eb702878840d /mastodon/streaming.py
parent65e2596d9bad2ac0a0c434ccc89700bd8e5d12ff (diff)
downloadmastodon.py-a29d278bf9cacf5f888561564f112312707e32fd.tar.gz
Add support for conversation streaming
Diffstat (limited to 'mastodon/streaming.py')
-rw-r--r--mastodon/streaming.py11
1 files changed, 10 insertions, 1 deletions
diff --git a/mastodon/streaming.py b/mastodon/streaming.py
index 1e1eefd..098863f 100644
--- a/mastodon/streaming.py
+++ b/mastodon/streaming.py
@@ -40,6 +40,11 @@ class StreamListener(object):
40 """A status has been deleted. status_id is the status' integer ID.""" 40 """A status has been deleted. status_id is the status' integer ID."""
41 pass 41 pass
42 42
43 def on_conversation(self, conversation):
44 """A direct message (in the direct stream) has been received. conversation
45 contains the resulting conversation dict."""
46 pass
47
43 def handle_heartbeat(self): 48 def handle_heartbeat(self):
44 """The server has sent us a keep-alive message. This callback may be 49 """The server has sent us a keep-alive message. This callback may be
45 useful to carry out periodic housekeeping tasks, or just to confirm 50 useful to carry out periodic housekeeping tasks, or just to confirm
@@ -151,7 +156,7 @@ class CallbackStreamListener(StreamListener):
151 Simple callback stream handler class. 156 Simple callback stream handler class.
152 Can optionally additionally send local update events to a separate handler. 157 Can optionally additionally send local update events to a separate handler.
153 """ 158 """
154 def __init__(self, update_handler = None, local_update_handler = None, delete_handler = None, notification_handler = None): 159 def __init__(self, update_handler = None, local_update_handler = None, delete_handler = None, notification_handler = None, conversation_handler = None):
155 super(CallbackStreamListener, self).__init__() 160 super(CallbackStreamListener, self).__init__()
156 self.update_handler = update_handler 161 self.update_handler = update_handler
157 self.local_update_handler = local_update_handler 162 self.local_update_handler = local_update_handler
@@ -178,3 +183,7 @@ class CallbackStreamListener(StreamListener):
178 def on_notification(self, notification): 183 def on_notification(self, notification):
179 if self.notification_handler != None: 184 if self.notification_handler != None:
180 self.notification_handler(notification) 185 self.notification_handler(notification)
186
187 def on_conversation(self, conversation):
188 if self.conversation_handler != None:
189 self.conversation_handler(conversation)
Powered by cgit v1.2.3 (git 2.41.0)