-
Notifications
You must be signed in to change notification settings - Fork 1
/
replies.py
53 lines (33 loc) · 1.38 KB
/
replies.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
from random import choice, randint
from replies_data import *
def randomly_capitalize(text):
if randint(0, 2): # randomly decide whether to capitalize
return text.capitalize()
return text
def random_smiley(can_be_empty=True):
# NOTE: `☺` is more probable if smiley cannot be empty
return choice([':)', '☺', '😇', '' if can_be_empty else '☺'])
def random_exclamation(can_be_empty=True):
# NOTE: `!` is more probable if exclamation cannot be empty
return choice(['!', '.', '' if can_be_empty else '!'])
def get_hello():
return randomly_capitalize(choice(hello))
def get_thank():
return randomly_capitalize(choice(thanks)) + ' ' + random_smiley()
def get_thank_reply():
return randomly_capitalize(choice(thank_replies)) + random_exclamation()
def get_fine_reply():
return randomly_capitalize(choice(fine_replies)) + random_exclamation()
def get_did_not_understand_reply():
return randomly_capitalize(choice(did_not_understand))
def get_sensor_reply(sensor_type, intent, result='default', value=None):
reply = choice(sensor_replies[sensor_type][intent][result])
kwargs = {}
if '{value}' in reply:
kwargs['value'] = value
if '{yes}' in reply:
kwargs['yes'] = choice(yes)
if '{no}' in reply:
kwargs['no'] = choice(no)
reply = reply.format_map(kwargs)
return randomly_capitalize(reply)