-
Notifications
You must be signed in to change notification settings - Fork 0
/
Text.py
39 lines (28 loc) · 1.01 KB
/
Text.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
import os
import random
class TextGenerator:
def getRandomLineFromTxt(self, filename):
return random.choice(list(open(os.path.join(os.path.dirname(
__file__), 'text/%s.txt' % filename), encoding="utf-8"))).rstrip().title()
def getAdjective(self):
return self.getRandomLineFromTxt('adjectives')
def getNoun(self):
return self.getRandomLineFromTxt('nouns')
def getJob(self):
return self.getRandomLineFromTxt('jobs')
def getWizardName(self):
name = '%s %s %s' % (
self.getAdjective(),
self.getNoun(),
self.getJob()
)
return name
def randomEmoji(self):
return self.getRandomLineFromTxt('emojis')
def randomEmojiText(self):
return self.getRandomLineFromTxt('emojitext')
def getRandomTweetText(self):
name = self.getWizardName()
emoji = self.randomEmoji()
emojiText = self.randomEmojiText()
return u'✦ %s ✦\n%s: %s' % (name, emojiText, emoji)