From 827b767eb221e50fa949ed34a529afad8a2a8490 Mon Sep 17 00:00:00 2001 From: joausaga Date: Wed, 12 Nov 2014 12:05:52 +0100 Subject: [PATCH] Extend on_data method by including a conditional to process warning messages and add the definition of the method to manage those warning messages --- tweepy/streaming.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 736cffa..b27e8f3 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -68,6 +68,9 @@ class StreamListener(object): elif 'disconnect' in data: if self.on_disconnect(data['disconnect']) is False: return False + elif 'warning' in data: + if self.on_warning(data['warning']) is False: + return False else: logging.error("Unknown message type: " + str(raw_data)) @@ -99,7 +102,7 @@ class StreamListener(object): return def on_limit(self, track): - """Called when a limitation notice arrvies""" + """Called when a limitation notice arrives""" return def on_error(self, status_code): @@ -117,6 +120,10 @@ class StreamListener(object): https://dev.twitter.com/docs/streaming-apis/messages#Disconnect_messages_disconnect """ return + + def on_warning(self, notice): + """Called when a disconnection warning message arrives""" + return class ReadBuffer(object): -- 2.25.1