From ed4b5ee69f5fc666e41ec3fcd2ba594818dc56a8 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 3 Aug 2016 23:00:52 -0400 Subject: [PATCH] trump only tweets --- App.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/App.py b/App.py index 7b367d9..024f669 100644 --- a/App.py +++ b/App.py @@ -20,10 +20,16 @@ class listener(StreamListener): def on_data(self, data): data = json.loads(data) - print(data.get("text")) + print(data) + text = data.get('text') + user = data.get('user') + screen_name = user.get('screen_name') payload = {'username' : 'Trump', 'icon_url' : avatar, 'text' : data.get("text")} - r = http.request('POST',hook ,headers={'Content-Type':'application/json'} ,body=json.dumps(payload)) - print(r.read()) + print(screen_name) + if screen_name == 'realDonaldTrump': + print("sending ... ") + r = http.request('POST',hook ,headers={'Content-Type':'application/json'} ,body=json.dumps(payload)) + print(r.read()) return True def on_error(self, status):