Last active
August 29, 2015 14:02
-
-
Save wadey/b4b15017bff23f32b4bc to your computer and use it in GitHub Desktop.
World Cup Slack Bot (with delay for no spoilers)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
import json | |
from twitter import TwitterStream, OAuth | |
import requests | |
import settings | |
twitter_stream = TwitterStream( | |
auth=OAuth( | |
settings.TOKEN, | |
settings.TOKEN_KEY, | |
settings.CON_SECRET, | |
settings.CON_SECRET_KEY)) | |
iterator = twitter_stream.statuses.filter(follow='2567530321') | |
for tweet in iterator: | |
print tweet | |
if u'text' in tweet and tweet[u'user'][u'id_str'] == '2567530321': | |
text = tweet[u'text'] | |
time.sleep(120) | |
payload = { | |
'text': text, | |
'icon_emoji': ':soccer:', | |
'username': 'betagoal', | |
} | |
requests.post(settings.SLACK_URL, json.dumps(payload)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment