forked from HenryWConklin/barkdetect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post.py
executable file
·53 lines (42 loc) · 1.43 KB
/
post.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#!/usr/bin/env python
# Posts a random bark string to twitter
import random
#Uses https://github.com/bear/python-twitter
import twitter
def genPost():
words = ['bark','woof','ruff']
upperWords = ['Bark', 'Woof', 'Ruff']
punc = ['!', '.']
numWords = random.randint(1, 10)
s = ''
hashTag = False
sentenceBegin = True
for x in range(numWords):
if sentenceBegin:
if random.random() > .66:
hashTag = True
s += '#'
s += random.choice(upperWords)
sentenceBegin = False
else:
if hashTag:
s += random.choice(upperWords)
else:
s += random.choice(words)
if random.random() > .5 or x == numWords-1:
sentenceBegin = True
if not hashTag:
s += random.choice(punc)
hashTag = False
if not hashTag:
s += ' '
return s
import ConfigParser
if __name__ == "__main__":
config = ConfigParser.RawConfigParser()
config.read('private.conf')
api = twitter.Api(consumer_key=config.get('TwitterKeys','consumer_key'),
consumer_secret=config.get('TwitterKeys','consumer_secret'),
access_token_key=config.get('TwitterKeys','access_token'),
access_token_secret=config.get('TwitterKeys', 'access_token_secret'))
api.PostUpdate(genPost())