|
1 | | -import random |
| 1 | +import json |
| 2 | +from pathlib import Path |
2 | 3 |
|
3 | 4 | from cloudbot import hook |
| 5 | +from cloudbot.util.textgen import TextGenerator |
4 | 6 |
|
| 7 | +love_data = {} |
5 | 8 |
|
6 | | -@hook.command("lurve","luff", "luv") |
7 | | -def lurve(text, nick, message): |
8 | | - """lurves all over <user>""" |
9 | | - target = text.strip() |
10 | 9 |
|
11 | | - # Use {N} to represent the person's nickname who is performing the action |
12 | | - # Use {T} to represent the person's nickname who is the target of the action |
13 | | - loving = [ |
14 | | - "{N} wraps arms around {T} and clings forever", |
15 | | - "{N} cuddles {T} in the fluffiest blanket ever", |
16 | | - "{N} lays their head on the lap of {T} and goes to sleep, dreaming da best sweet dreams", |
17 | | - "{N} caresses {T}'s hair", |
18 | | - "{N} caresses {T}'s cheek", |
19 | | - "{N} plants a shy kiss on {T}'s cheek", |
20 | | - "{N} gives {T} a BIIIIIIIIG hug!!!", |
21 | | - "{N} lovingly tackles {T} into a pit of the softest pillows ever", |
22 | | - "{N} cheers happily for {T}!!", |
23 | | - "{N} pulls {T} back into bed for more cuddles ♥~", |
24 | | - "{N} snuggles {T} for Netflix and chili popcorn", |
25 | | - "{N} happily kisses {T} on the cheek", |
26 | | - "{N} shares a milkshake with {T}" |
27 | | - ]; |
| 10 | +@hook.on_start |
| 11 | +def load_love(bot): |
| 12 | + love_data.clear() |
| 13 | + data_file = Path(bot.data_dir) / "lurve.json" |
| 14 | + with data_file.open(encoding='utf-8') as f: |
| 15 | + love_data.update(json.load(f)) |
| 16 | + |
28 | 17 |
|
29 | | - out = "{}".format(random.choice(loving)) |
30 | | - out = out.replace("{N}", nick) |
31 | | - out = out.replace("{T}", target) |
| 18 | +@hook.command("lurve", "luff", "luv") |
| 19 | +def lurve(text, nick, message): |
| 20 | + """lurves all over <user>""" |
| 21 | + data = { |
| 22 | + 'nick': nick, |
| 23 | + 'target': text, |
| 24 | + } |
32 | 25 |
|
33 | | - message(out) |
| 26 | + generator = TextGenerator(love_data['templates'], love_data['parts'], variables=data) |
| 27 | + message(generator.generate_string()) |
0 commit comments