-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtraealfajores.py
37 lines (28 loc) · 888 Bytes
/
traealfajores.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import json
from tweepy.streaming import StreamListener
from tweepy import Stream
from twitterapi import TwitterAPI
twitter = TwitterAPI()
class TraeAlfajoreListener(StreamListener):
"""
A listener handles to handle tweets from Ezeiza
"""
def on_data(self, data):
tweet = json.loads(data)
twitter.tweet_text(
'@{user} Trae alfajores!'.format(
user=tweet.get('user').get('screen_name')
),
tweet.get('id')
)
return True
def on_error(self, status):
if status == 420:
return False
def on_timeout(self):
print 'Timeout...'
return True # Don't kill the stream
if __name__ == '__main__':
l = TraeAlfajoreListener()
stream = Stream(twitter.auth, l)
stream.filter(track=['Aeropuerto Internacional de Ezeiza - Ministro Pistarini'])