Skip to content

Commit d0f8cd9

Browse files
committed
Move cake data to data/cake.json
1 parent 2f7f514 commit d0f8cd9

2 files changed

Lines changed: 61 additions & 11 deletions

File tree

data/cake.json

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
{
2+
"templates": [
3+
"{method} {user} a {flavor} {size} {type} cake and serves it with a small {side}!"
4+
],
5+
"parts": {
6+
"method": [
7+
"makes",
8+
"gives",
9+
"gets",
10+
"buys"
11+
],
12+
"flavor": [
13+
"tasty",
14+
"delectable",
15+
"delicious",
16+
"yummy",
17+
"toothsome",
18+
"scrumptious",
19+
"luscious"
20+
],
21+
"size": [
22+
"small",
23+
"little",
24+
"mid-sized",
25+
"medium-sized",
26+
"large",
27+
"gigantic"
28+
],
29+
"type": [
30+
"Chocolate",
31+
"Ice Cream",
32+
"Angel",
33+
"Boston Cream",
34+
"Birthday",
35+
"Bundt",
36+
"Carrot",
37+
"Coffee",
38+
"Devils",
39+
"Fruit",
40+
"Gingerbread",
41+
"Pound",
42+
"Red Velvet",
43+
"Stack",
44+
"Welsh",
45+
"Yokan"
46+
],
47+
"side": [
48+
"glass of chocolate milk",
49+
"bowl of ice cream",
50+
"jar of cookies",
51+
"side of chocolate sauce"
52+
]
53+
}
54+
}

plugins/foods.py

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010

1111
nick_re = re.compile("^[A-Za-z0-9_|.\-\]\[\{\}\*\`]*$", re.I)
1212

13-
cakes = ['Chocolate', 'Ice Cream', 'Angel', 'Boston Cream', 'Birthday', 'Bundt', 'Carrot', 'Coffee', 'Devils', 'Fruit',
14-
'Gingerbread', 'Pound', 'Red Velvet', 'Stack', 'Welsh', 'Yokan']
15-
1613
cookies = ['Chocolate Chip', 'Oatmeal', 'Sugar', 'Oatmeal Raisin', 'Macadamia Nut', 'Jam Thumbprint', 'Mexican Wedding',
1714
'Biscotti', 'Oatmeal Cranberry', 'Chocolate Fudge', 'Peanut Butter', 'Pumpkin', 'Lemon Bar',
1815
'Chocolate Oatmeal Fudge', 'Toffee Peanut', 'Danish Sugar', 'Triple Chocolate', 'Oreo']
@@ -79,6 +76,7 @@
7976
steak_data = {}
8077
milkshake_data = {}
8178
kebab_data = {}
79+
cake_data = {}
8280

8381

8482
def is_valid(target):
@@ -127,6 +125,7 @@ def load_foods(bot):
127125
load_template_data(bot, "steak.json", steak_data)
128126
load_template_data(bot, "milkshake.json", milkshake_data)
129127
load_template_data(bot, "kebab.json", kebab_data)
128+
load_template_data(bot, "cake.json", cake_data)
130129

131130

132131
@asyncio.coroutine
@@ -157,15 +156,12 @@ def cake(text, action):
157156
if not is_valid(user):
158157
return "I can't give a cake to that user."
159158

160-
cake_type = random.choice(cakes)
161-
size = random.choice(['small', 'little', 'mid-sized', 'medium-sized', 'large', 'gigantic'])
162-
flavor = random.choice(['tasty', 'delectable', 'delicious', 'yummy', 'toothsome', 'scrumptious', 'luscious'])
163-
method = random.choice(['makes', 'gives', 'gets', 'buys'])
164-
side_dish = random.choice(['glass of chocolate milk', 'bowl of ice cream', 'jar of cookies',
165-
'side of chocolate sauce'])
159+
generator = textgen.TextGenerator(
160+
cake_data["templates"], cake_data["parts"], variables={"user": user}
161+
)
166162

167-
action("{} {} a {} {} {} cake and serves it with a small {}!".format(method, user, flavor, size, cake_type,
168-
side_dish))
163+
# act out the message
164+
action(generator.generate_string())
169165

170166

171167
@asyncio.coroutine

0 commit comments

Comments
 (0)