Skip to content

Instantly share code, notes, and snippets.

@wadey
Last active August 29, 2015 14:02
Show Gist options
  • Save wadey/b4b15017bff23f32b4bc to your computer and use it in GitHub Desktop.
Save wadey/b4b15017bff23f32b4bc to your computer and use it in GitHub Desktop.
World Cup Slack Bot (with delay for no spoilers)
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