|
1 | 1 | # halaal for gonzobot |
2 | | -import random |
| 2 | +import json |
| 3 | +from pathlib import Path |
3 | 4 |
|
4 | 5 | from cloudbot import hook |
| 6 | +from cloudbot.util.textgen import TextGenerator |
5 | 7 |
|
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 = {} |
13 | 10 |
|
14 | | -quality = [ |
15 | | - 'fresh made', |
16 | | - 'left over', |
17 | | - 'just out of the oven' |
18 | 11 |
|
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)) |
20 | 18 |
|
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) |
81 | 21 |
|
82 | 22 |
|
83 | 23 | @hook.command('halaal', 'halal', autohelp=False) |
84 | 24 | def serving(text, action): |
85 | 25 | """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 |
91 | 30 | 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()) |
93 | 35 |
|
94 | 36 |
|
95 | 37 | @hook.command('kosher', autohelp=False) |
96 | 38 | def kserving(text, action): |
97 | 39 | """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 |
101 | 44 | 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()) |
103 | 49 |
|
104 | 50 | # written by ilgnome |
105 | 51 | # find me in #gonzobot |
0 commit comments