import tweepy
-def callback(status):
-
- print status.text
+def callback(t, stream_object):
+ if t == 'status':
+ print stream_object.text
+ elif t == 'delete':
+ print 'delete!!! id = %s' % stream_object['id']
+ elif t == 'limit':
+ print 'limit!!! track=%s' % stream_object['track']
# Prompt for login credentials and setup stream object
username = raw_input('Twitter username: ')
if self.running is False:
break
conn.close()
- print 'snoozing...'
sleep(self.snooze_time)
- print 'ok im awake!'
except Exception:
# any other exception is fatal, so kill loop
break
# turn json data into status object
if 'in_reply_to_status_id' in data:
status = parse_status(data, self.api)
- self.callback(status)
-
- # TODO: we should probably also parse delete/track messages
- # and pass to a callback
+ self.callback('status', status)
+ elif 'delete' in data:
+ self.callback('delete', json.loads(data)['delete']['status'])
+ elif 'limit' in data:
+ self.callback('limit', json.loads(data)['limit'])
def firehose(self, count=None, ):
if self.running: