From 305cff386a2f6331c86b9026919402c73b0c673d Mon Sep 17 00:00:00 2001 From: Tetsuya Shinone Date: Sat, 30 Nov 2013 09:49:24 +0900 Subject: [PATCH] Add some callback methods. --- tweepy/streaming.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tweepy/streaming.py b/tweepy/streaming.py index 3a5651a..de30c2c 100644 --- a/tweepy/streaming.py +++ b/tweepy/streaming.py @@ -48,6 +48,14 @@ class StreamListener(object): delete = data['delete']['status'] if self.on_delete(delete['id'], delete['user_id']) is False: return False + elif 'event' in data: + status = Status.parse(self.api, data) + if self.on_event(status) is False: + return False + elif 'direct_message' in data: + status = Status.parse(self.api, data) + if self.on_direct_message(status) is False: + return False elif 'limit' in data: if self.on_limit(data['limit']['track']) is False: return False @@ -65,6 +73,14 @@ class StreamListener(object): """Called when a delete notice arrives for a status""" return + def on_event(self, status): + """Called when a new event arrives""" + return + + def on_direct_message(self, status): + """Called when a new direct message arrives""" + return + def on_limit(self, track): """Called when a limitation notice arrvies""" return -- 2.25.1