Skip to content

Commit 3045676

Browse files
committed
Move cookie data to data/cookies.json
1 parent af382fa commit 3045676

2 files changed

Lines changed: 61 additions & 12 deletions

File tree

data/cookies.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} cookie and serves it with a {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+
"medium-sized",
25+
"large",
26+
"gigantic"
27+
],
28+
"type": [
29+
"Chocolate Chip",
30+
"Oatmeal",
31+
"Sugar",
32+
"Oatmeal Raisin",
33+
"Macadamia Nut",
34+
"Jam Thumbprint",
35+
"Mexican Wedding",
36+
"Biscotti",
37+
"Oatmeal Cranberry",
38+
"Chocolate Fudge",
39+
"Peanut Butter",
40+
"Pumpkin",
41+
"Lemon Bar",
42+
"Chocolate Oatmeal Fudge",
43+
"Toffee Peanut",
44+
"Danish Sugar",
45+
"Triple Chocolate",
46+
"Oreo"
47+
],
48+
"side": [
49+
"glass of milk",
50+
"bowl of ice cream",
51+
"bowl of chocolate sauce"
52+
]
53+
}
54+
}

plugins/foods.py

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

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

13-
cookies = ['Chocolate Chip', 'Oatmeal', 'Sugar', 'Oatmeal Raisin', 'Macadamia Nut', 'Jam Thumbprint', 'Mexican Wedding',
14-
'Biscotti', 'Oatmeal Cranberry', 'Chocolate Fudge', 'Peanut Butter', 'Pumpkin', 'Lemon Bar',
15-
'Chocolate Oatmeal Fudge', 'Toffee Peanut', 'Danish Sugar', 'Triple Chocolate', 'Oreo']
16-
17-
1813
sandwich_data = {}
1914
taco_data = {}
2015
coffee_data = {}
@@ -43,6 +38,7 @@
4338
kebab_data = {}
4439
cake_data = {}
4540
potato_data = {}
41+
cookie_data = {}
4642

4743

4844
def is_valid(target):
@@ -93,6 +89,7 @@ def load_foods(bot):
9389
load_template_data(bot, "kebab.json", kebab_data)
9490
load_template_data(bot, "cake.json", cake_data)
9591
load_template_data(bot, "potato.json", potato_data)
92+
load_template_data(bot, "cookies.json", cookie_data)
9693

9794

9895
@asyncio.coroutine
@@ -142,14 +139,12 @@ def cookie(text, action):
142139
if not is_valid(user):
143140
return "I can't give a cookie to that user."
144141

145-
cookie_type = random.choice(cookies)
146-
size = random.choice(['small', 'little', 'medium-sized', 'large', 'gigantic'])
147-
flavor = random.choice(['tasty', 'delectable', 'delicious', 'yummy', 'toothsome', 'scrumptious', 'luscious'])
148-
method = random.choice(['makes', 'gives', 'gets', 'buys'])
149-
side_dish = random.choice(['glass of milk', 'bowl of ice cream', 'bowl of chocolate sauce'])
142+
generator = textgen.TextGenerator(
143+
cookie_data["templates"], cookie_data["parts"], variables={"user": user}
144+
)
150145

151-
action("{} {} a {} {} {} cookie and serves it with a {}!".format(method, user, flavor, size, cookie_type,
152-
side_dish))
146+
# act out the message
147+
action(generator.generate_string())
153148

154149

155150
@asyncio.coroutine

0 commit comments

Comments
 (0)