-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrandom_message.py
48 lines (37 loc) · 1.38 KB
/
random_message.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
import random
class Reminder:
def __init__(self):
self.languages = []
self.shortkeys = []
self.messages = {}
self.index = 0
with open("messages/conf.txt", 'r') as f:
msg = f.read().split('\n')[:-1]
for confs in msg:
conf = confs.split('-')
self.languages.append(conf[0])
self.shortkeys.append(conf[1])
for lang in self.languages:
key = self.shortkeys[self.languages.index(lang)]
with open(f"messages/message-{lang}.txt", 'r') as f:
msg = f.read().split('\n')[:-1]
self.messages[key] = msg
def getMessage(self, lang, index):
return self.messages[lang][index]
def getAllMessage(self, lang):
return self.messages[lang]
def getRandom(self, lang):
return random.choice(self.messages[lang])
def getRandomIndexed(self, lang):
return self.getMessage(lang, self.index)
def randomIndex(self):
self.index = random.randint(0,2)
def getAvailable(self):
return self.languages
if __name__ == "__main__":
rem = Reminder()
choosen = input("which language:")
if choosen in rem.getAvailable():
choosen = rem.shortkeys[rem.languages.index(choosen)]
for message in rem.getAllMessage(choosen):
print(message)