Skip to content

Commit fe85047

Browse files
committed
Move halal and kosher data to data files
1 parent a4f5c08 commit fe85047

3 files changed

Lines changed: 132 additions & 83 deletions

File tree

data/food/halal.json

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{
2+
"target_templates": [
3+
"Serves {target} {quantity} {quality} {dish}"
4+
],
5+
"templates": [
6+
"has {quantity} {quality} {dish}"
7+
],
8+
"parts": {
9+
"quantity": [
10+
"a little bit of",
11+
"a heaping pile of",
12+
"a moderate serving of",
13+
"a taste of",
14+
"just a smell of"
15+
],
16+
"quality": [
17+
"fresh made",
18+
"left over",
19+
"just out of the oven"
20+
],
21+
"dish": [
22+
"Rice and Goat Meat",
23+
"Goat Curry",
24+
"Hummus bi Tahina",
25+
"Läghmän",
26+
"Mutton biryani",
27+
"Kabuli palao",
28+
"Shakshouka",
29+
"Mutton Msala",
30+
"Fatteh Betnjan",
31+
"Caprese stuffed chicken breast",
32+
"Maqloobeh",
33+
"Koofteh berenji",
34+
"Fish Makkanwala",
35+
"Szechwan"
36+
]
37+
}
38+
}

data/food/kosher.json

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
{
2+
"target_templates": [
3+
"Serves {target} {quantity} {quality} {dish}"
4+
],
5+
"templates": [
6+
"has {quantity} {quality} {dish}"
7+
],
8+
"parts": {
9+
"quantity": [
10+
"a little bit of",
11+
"a heaping pile of",
12+
"a moderate serving of",
13+
"a taste of",
14+
"just a smell of"
15+
],
16+
"quality": [
17+
"fresh made",
18+
"left over",
19+
"just out of the oven"
20+
],
21+
"dish": [
22+
"gefilte fish",
23+
"matzo ball soup",
24+
"cholent",
25+
"sufganiyot",
26+
"cream cheese with lox bagel",
27+
"lamb merguez with lentils and pears",
28+
"warm apple streusel with ice cream on top",
29+
"mushroom and truffle pizza",
30+
"lemon and rosemary salad with a side of rice",
31+
"latkes with applesauce",
32+
"challah french toast",
33+
"grilled fish tacos with chili-lime dressing",
34+
"date charoset",
35+
"huevos haminados",
36+
"baba-ghanouj",
37+
"bastani with freshly baked pita",
38+
"hummus with perfectly fried falafel",
39+
"mujadrah with warm bread",
40+
"shishlik with red peppers, mushrooms, and onion",
41+
"spicy shakshouka with french bread",
42+
"hadgi badah with a tall glass of apple juice",
43+
"malawah with a large glass of milk",
44+
"sweet kugel with extra sugar on top",
45+
"hamantaschen with date and raspberry filling",
46+
"marbled halva with almonds on top",
47+
"labna with a side of chili sauce",
48+
"polow shirin with extra pomegranate",
49+
"lamb bademjan"
50+
"beef kubbeh with extra chili peppers",
51+
"beef shawarma with a side of hummus and rice",
52+
"lamb and mushroom kofta with a large coke",
53+
"cheese and spinach sambousek",
54+
"bamieh with a side of grilled chicken",
55+
"chicken tagine with saffron rice and a slice of lechuch",
56+
"kofta mishmisheya with grilled vegetables",
57+
"charoset with day old matzah",
58+
"sour cherry rugelach",
59+
"orange-scented flan with dulce de leche syrup",
60+
"brisket with potatoes and a spinach salad",
61+
"bouikos con kashkaval",
62+
"lemon-rice soup with soda crackers"
63+
]
64+
}
65+
}

plugins/halal.py

Lines changed: 29 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,51 @@
11
# halaal for gonzobot
2-
import random
2+
import json
3+
from pathlib import Path
34

45
from cloudbot import hook
6+
from cloudbot.util.textgen import TextGenerator
57

6-
quantity = [
7-
'a little bit of',
8-
'a heaping pile of',
9-
'a moderate serving of',
10-
'a taste of',
11-
'just a smell of',
12-
]
8+
halal_data = {}
9+
kosher_data = {}
1310

14-
quality = [
15-
'fresh made',
16-
'left over',
17-
'just out of the oven'
1811

19-
]
12+
def load_data(bot):
13+
def load_file(file, data_dict):
14+
data_dict.clear()
15+
path = Path(bot.data_dir) / file
16+
with path.open(encoding='utf-8') as f:
17+
data_dict.update(json.load(f))
2018

21-
dish = [
22-
'Rice and Goat Meat',
23-
'Goat Curry',
24-
'Hummus bi Tahina',
25-
'Läghmän',
26-
'Mutton biryani',
27-
'Kabuli palao',
28-
'Shakshouka',
29-
'Mutton Msala',
30-
'Fatteh Betnjan',
31-
'Caprese stuffed chicken breast',
32-
'Maqloobeh',
33-
'Koofteh berenji',
34-
'Fish Makkanwala',
35-
'Szechwan'
36-
]
37-
38-
kdish = [
39-
'gefilte fish',
40-
'matzo ball soup',
41-
'cholent',
42-
'sufganiyot',
43-
'cream cheese with lox bagel',
44-
'lamb merguez with lentils and pears',
45-
'warm apple streusel with ice cream on top',
46-
'mushroom and truffle pizza',
47-
'lemon and rosemary salad with a side of rice',
48-
'latkes with applesauce',
49-
'challah french toast',
50-
'grilled fish tacos with chili-lime dressing',
51-
'date charoset',
52-
'huevos haminados',
53-
'baba-ghanouj',
54-
'bastani with freshly baked pita',
55-
'hummus with perfectly fried falafel',
56-
'mujadrah with warm bread',
57-
'shishlik with red peppers, mushrooms, and onion',
58-
'spicy shakshouka with french bread',
59-
'hadgi badah with a tall glass of apple juice',
60-
'malawah with a large glass of milk',
61-
'sweet kugel with extra sugar on top',
62-
'hamantaschen with date and raspberry filling',
63-
'marbled halva with almonds on top',
64-
'labna with a side of chili sauce',
65-
'polow shirin with extra pomegranate',
66-
'lamb bademjan'
67-
'beef kubbeh with extra chili peppers',
68-
'beef shawarma with a side of hummus and rice',
69-
'lamb and mushroom kofta with a large coke',
70-
'cheese and spinach sambousek',
71-
'bamieh with a side of grilled chicken',
72-
'chicken tagine with saffron rice and a slice of lechuch',
73-
'kofta mishmisheya with grilled vegetables',
74-
'charoset with day old matzah',
75-
'sour cherry rugelach',
76-
'orange-scented flan with dulce de leche syrup',
77-
'brisket with potatoes and a spinach salad',
78-
'bouikos con kashkaval',
79-
'lemon-rice soup with soda crackers'
80-
]
19+
load_file("halal.json", halal_data)
20+
load_file("kosher.json", kosher_data)
8121

8222

8323
@hook.command('halaal', 'halal', autohelp=False)
8424
def serving(text, action):
8525
"""Serves halaal dishes to some one in the channel"""
86-
diner = text.strip()
87-
88-
if diner == '':
89-
action('has {} {} {}'.format(random.choice(quantity), random.choice(quality), random.choice(dish)))
90-
26+
data = {}
27+
if text:
28+
templates = halal_data['target_templates']
29+
data['target'] = text
9130
else:
92-
action('Serves {} {} {} {}'.format(diner, random.choice(quantity), random.choice(quality), random.choice(dish)))
31+
templates = halal_data['templates']
32+
33+
generator = TextGenerator(templates, halal_data['parts'], variables=data)
34+
action(generator.generate_string())
9335

9436

9537
@hook.command('kosher', autohelp=False)
9638
def kserving(text, action):
9739
"""Servers a Kosher dish to some one in the channel. Part of halal.py. Made with help of snoonet user Yat"""
98-
kdiner = text.strip()
99-
if kdiner == '':
100-
action('has {} {} {}'.format(random.choice(quantity), random.choice(quality), random.choice(kdish)))
40+
data = {}
41+
if text:
42+
templates = kosher_data['target_templates']
43+
data['target'] = text
10144
else:
102-
action('Serves {} {} {} {}'.format(kdiner, random.choice(quantity), random.choice(quality), random.choice(kdish)))
45+
templates = kosher_data['templates']
46+
47+
generator = TextGenerator(templates, kosher_data['parts'], variables=data)
48+
action(generator.generate_string())
10349

10450
# written by ilgnome
10551
# find me in #gonzobot

0 commit comments

Comments
 (0)