Commit 98589b5f authored by Josh Roesslein's avatar Josh Roesslein
Browse files

Added delete/limit message parsing.

parent f2662565
......@@ -3,9 +3,13 @@ from getpass import getpass
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: ')
......@@ -59,9 +59,7 @@ class Stream(object):
if self.running is False:
print 'snoozing...'
print 'ok im awake!'
except Exception:
# any other exception is fatal, so kill loop
......@@ -96,10 +94,11 @@ class Stream(object):
# turn json data into status object
if 'in_reply_to_status_id' in data:
status = parse_status(data, self.api)
# 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:
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment