Skip to content

Commit

Permalink
Merge pull request #141 from DSPhat/python3.4
Browse files Browse the repository at this point in the history
Add taco command
  • Loading branch information
dmptrluke committed Mar 27, 2015
2 parents 3220fbd + 04016d7 commit 80264a5
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 1 deletion.
75 changes: 75 additions & 0 deletions data/taco.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
{
"templates": [
"hands {user} a {quality} {type} taco filled with {meat} and topped with {topping}, {topping} and {topping}!"
],
"parts": {
"type": [
"hard-shell",
"soft-shell",
"crispy",
"puffy",
"Indian"
],
"quality": [
"spicy",
"mild",
"delicious",
[
"boring",
1
],
[
"disgusting",
1
],
"perfect"
],
"meat": [
"minced beef",
"chicken",
"refried beans"
],
"topping": [
[
"guacamole",
10
],
[
"salsa",
10
],
[
"sour cream",
10
],
"cheese",
"lettuce",
"tomatoes",
"avocado",
"onion",
"scallions",
"jalapeños",
"capsicum",
[
"ghost chili",
1
],
[
"olives",
1
],
[
"pineapple",
1
],
[
"raspberry",
1
],
[
"potato",
1
]
]
}
}
20 changes: 19 additions & 1 deletion plugins/foods.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@ def load_foods(bot):
"""
:type bot: cloudbot.bot.CloudBot
"""
global sandwich_data
global sandwich_data, taco_data

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

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


@asyncio.coroutine
@hook.command
Expand Down Expand Up @@ -143,3 +146,18 @@ def sandwich(text, action):

# act out the message
action(generator.generate_string())

@asyncio.coroutine
@hook.command
def taco(text, action):
"""<user> - give a taco to <user>"""
user = text.strip()

if not is_valid(user):
return "I can't give a taco to that user."

generator = textgen.TextGenerator(taco_data["templates"], taco_data["parts"],
variables={"user": user})

# act out the message
action(generator.generate_string())

0 comments on commit 80264a5

Please sign in to comment.