-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseinfeld_bot.py
32 lines (25 loc) · 1.04 KB
/
seinfeld_bot.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
import requests
def send_simple_message(twitter_text):
return requests.post(
"https://api.mailgun.net/v3/sandboxWTVIDTHEYPROVIDEYOU.mailgun.org/messages",
auth=("api", ""),
data={"from": "Mailgun Sandbox <[email protected]>",
"to": "Whomever <[email protected]>, Whomever2 <[email protected]>",
"subject": "On #Seinfeld tonight",
"text": twitter_text})
from twitter import Twitter, OAuth, TwitterHTTPError, TwitterStream
import json
#Twitter Dev Tokens
ACCESS_TOKEN = ''
ACCESS_SECRET = ''
CONSUMER_KEY = ''
CONSUMER_SECRET = ''
oauth = OAuth(ACCESS_TOKEN, ACCESS_SECRET, CONSUMER_KEY, CONSUMER_SECRET)
twitter = Twitter(
auth=oauth)
results = twitter.statuses.user_timeline(screen_name="SeinfeldTV")
for status in results:
if "#Seinfeld tonight" in status["text"].encode("ascii", "ignore"):
print "(%s) %s" % (status["created_at"], status["text"].encode("ascii", "ignore"))
send_simple_message(status["text"].encode("ascii", "ignore"))
break