Skip to content

Commit 4c6cdd7

Browse files
authored
Merge branch 'gonzobot' into gonzobot+regex-priorities
2 parents 66fec7e + 5dd1722 commit 4c6cdd7

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

data/rice.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"templates": [
3+
"hands {user} a bowl of {rice} rice."
4+
],
5+
"parts": {
6+
"rice": [
7+
"Uncle Ben's Basmati",
8+
"Uncle Ben's Golden Vegetable ",
9+
"Japanese Koshihikari",
10+
"Camargue red",
11+
"Brown",
12+
"Wehani",
13+
"Jasmine",
14+
"Sticky",
15+
"Hokkien fried",
16+
"Bibimbap",
17+
"Dal bhat",
18+
"Onigiri",
19+
"Long-grain Nychaki",
20+
"Iranian Domsiah",
21+
"Italian Vialone Nano",
22+
"Nàng Thơm Chợ Đào",
23+
"Htamanè",
24+
"Aromic Tulaipanji"
25+
]
26+
}
27+
}

plugins/foods.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def load_foods(bot):
6565
"""
6666
:type bot: cloudbot.bot.CloudBot
6767
"""
68-
global sandwich_data, taco_data, coffee_data, noodles_data, muffin_data, scone_data, \
68+
global sandwich_data, taco_data, coffee_data, noodles_data, muffin_data, scone_data, rice_data, \
6969
tea_data, keto_data, beer_data, cheese_data, pancake_data, chicken_data, \
7070
icecream_data, brekkie_data, doobie_data, pizza_data, chocolate_data, pasta_data, \
7171
nugget_data, cereal_data, pie_data, sushi_data, steak_data, milkshake_data, kebab_data
@@ -88,6 +88,9 @@ def load_foods(bot):
8888
with codecs.open(os.path.join(bot.data_dir, "scone.json"), encoding="utf-8") as f:
8989
scone_data = json.load(f)
9090

91+
with codecs.open(os.path.join(bot.data_dir, "rice.json"), encoding="utf-8") as f:
92+
rice_data = json.load(f)
93+
9194
with codecs.open(os.path.join(bot.data_dir, "tea.json"), encoding="utf-8") as f:
9295
tea_data = json.load(f)
9396

@@ -291,6 +294,20 @@ def scone(text, action):
291294
# act out the message
292295
action(generator.generate_string())
293296

297+
@asyncio.coroutine
298+
@hook.command
299+
def rice(text, action):
300+
"""<user> - give rice to <user>"""
301+
user = text.strip()
302+
303+
if not is_valid(user):
304+
return "I can't give rice to that user."
305+
306+
generator = textgen.TextGenerator(rice_data["templates"], rice_data["parts"],
307+
variables={"user": user})
308+
# act out the message
309+
action(generator.generate_string())
310+
294311
@asyncio.coroutine
295312
@hook.command
296313
def tea(text, action):

0 commit comments

Comments
 (0)