Skip to content

Commit c14ed73

Browse files
committed
first commit
0 parents  commit c14ed73

File tree

4 files changed

+28
-0
lines changed

4 files changed

+28
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.env

Procfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
worker: python loremricksum.py

loremricksum.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env python
2+
import os, json, io, tweepy, time, urllib2
3+
4+
CONSUMER_KEY = os.environ['CONSUMER_KEY']
5+
CONSUMER_SECRET = os.environ['CONSUMER_SECRET']
6+
ACCESS_KEY = os.environ['ACCESS_KEY']
7+
ACCESS_SECRET = os.environ['ACCESS_SECRET']
8+
9+
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET)
10+
auth.set_access_token(ACCESS_TOKEN, ACCESS_SECRET)
11+
api = tweepy.API(auth)
12+
13+
def runBot():
14+
quote = urllib2.urlopen('http://loremricksum.com/api/?paragraphs=1&quotes=1')
15+
text = json.load(quote)['data']
16+
tweet = json.dumps(text).strip("[]")
17+
api.update_status(tweet)
18+
19+
while True:
20+
try:
21+
runBot()
22+
except tweepy.TweepError as e:
23+
print(e.reason)
24+
time.sleep(3600)
25+

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
tweepy==3.5.0

0 commit comments

Comments
 (0)