Skip to content

Commit ff78f39

Browse files
committed
Move lurve data to a data file
1 parent cf33fd1 commit ff78f39

2 files changed

Lines changed: 38 additions & 26 deletions

File tree

data/lurve.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"templates": [
3+
"{nick} wraps arms around {target} and clings forever",
4+
"{nick} cuddles {target} in the fluffiest blanket ever",
5+
"{nick} lays their head on the lap of {target} and goes to sleep, dreaming da best sweet dreams",
6+
"{nick} caresses {target}'s hair",
7+
"{nick} caresses {target}'s cheek",
8+
"{nick} plants a shy kiss on {target}'s cheek",
9+
"{nick} gives {target} a BIIIIIIIIG hug!!!",
10+
"{nick} lovingly tackles {target} into a pit of the softest pillows ever",
11+
"{nick} cheers happily for {target}!!",
12+
"{nick} pulls {target} back into bed for more cuddles ♥~",
13+
"{nick} snuggles {target} for Netflix and chili popcorn",
14+
"{nick} happily kisses {target} on the cheek",
15+
"{nick} shares a milkshake with {target}"
16+
],
17+
"parts": {}
18+
}

plugins/lurve.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
import random
1+
import json
2+
from pathlib import Path
23

34
from cloudbot import hook
5+
from cloudbot.util.textgen import TextGenerator
46

7+
love_data = {}
58

6-
@hook.command("lurve","luff", "luv")
7-
def lurve(text, nick, message):
8-
"""lurves all over <user>"""
9-
target = text.strip()
109

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+
2817

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+
}
3225

33-
message(out)
26+
generator = TextGenerator(love_data['templates'], love_data['parts'], variables=data)
27+
message(generator.generate_string())

0 commit comments

Comments
 (0)