Skip to content

Commit 80264a5

Browse files
committed
Merge pull request #141 from DSPhat/python3.4
Add taco command
2 parents 3220fbd + 04016d7 commit 80264a5

File tree

2 files changed

+94
-1
lines changed

2 files changed

+94
-1
lines changed

data/taco.json

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{
2+
"templates": [
3+
"hands {user} a {quality} {type} taco filled with {meat} and topped with {topping}, {topping} and {topping}!"
4+
],
5+
"parts": {
6+
"type": [
7+
"hard-shell",
8+
"soft-shell",
9+
"crispy",
10+
"puffy",
11+
"Indian"
12+
],
13+
"quality": [
14+
"spicy",
15+
"mild",
16+
"delicious",
17+
[
18+
"boring",
19+
1
20+
],
21+
[
22+
"disgusting",
23+
1
24+
],
25+
"perfect"
26+
],
27+
"meat": [
28+
"minced beef",
29+
"chicken",
30+
"refried beans"
31+
],
32+
"topping": [
33+
[
34+
"guacamole",
35+
10
36+
],
37+
[
38+
"salsa",
39+
10
40+
],
41+
[
42+
"sour cream",
43+
10
44+
],
45+
"cheese",
46+
"lettuce",
47+
"tomatoes",
48+
"avocado",
49+
"onion",
50+
"scallions",
51+
"jalapeños",
52+
"capsicum",
53+
[
54+
"ghost chili",
55+
1
56+
],
57+
[
58+
"olives",
59+
1
60+
],
61+
[
62+
"pineapple",
63+
1
64+
],
65+
[
66+
"raspberry",
67+
1
68+
],
69+
[
70+
"potato",
71+
1
72+
]
73+
]
74+
}
75+
}

plugins/foods.py

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,14 @@ def load_foods(bot):
6565
"""
6666
:type bot: cloudbot.bot.CloudBot
6767
"""
68-
global sandwich_data
68+
global sandwich_data, taco_data
6969

7070
with codecs.open(os.path.join(bot.data_dir, "sandwich.json"), encoding="utf-8") as f:
7171
sandwich_data = json.load(f)
7272

73+
with codecs.open(os.path.join(bot.data_dir, "taco.json"), encoding="utf-8") as f:
74+
taco_data = json.load(f)
75+
7376

7477
@asyncio.coroutine
7578
@hook.command
@@ -143,3 +146,18 @@ def sandwich(text, action):
143146

144147
# act out the message
145148
action(generator.generate_string())
149+
150+
@asyncio.coroutine
151+
@hook.command
152+
def taco(text, action):
153+
"""<user> - give a taco to <user>"""
154+
user = text.strip()
155+
156+
if not is_valid(user):
157+
return "I can't give a taco to that user."
158+
159+
generator = textgen.TextGenerator(taco_data["templates"], taco_data["parts"],
160+
variables={"user": user})
161+
162+
# act out the message
163+
action(generator.generate_string())

0 commit comments

Comments
 (0)